I want to add a new column "Condition" based on the existing two columns, "target" and "response" and modify the contents in the new column to "target to response". But there is an error:
Please help! Thank you!
I want to add a new column "Condition" based on the existing two columns, "target" and "response" and modify the contents in the new column to "target to response". But there is an error:
Please help! Thank you!
It's better if you can paste reproducible data and code. Is this what you want to do, i.e. paste two columns?
library(tidyverse)
tribble(~col1, ~col2,
"a", "b",
"c", "d") |>
mutate(new_col = str_c(col1, col2, sep = " to "))
#> # A tibble: 2 × 3
#> col1 col2 new_col
#> <chr> <chr> <chr>
#> 1 a b a to b
#> 2 c d c to d
Created on 2022-06-21 by the reprex package (v2.0.1)