I am creating a new column T_BE which I want to take a value of 1 if an existing column, theme, contains "Business and Energy".
The row I am concerned with has "Business and Energy; Economy" as the entry for theme.
Normally I use
df$T_BE <- 0
df$T_BE[SOAS$theme == "Business and Energy"] <- 1
but this time the factor is not exact.
I have tried:
df$T_BE <- 0
df$T_BE["Business and Energy" %in% df$theme] <- 1
but it doesn't work.
I will also want to do a similar selection of "Economy" to make new column, T_E
df%T_E <- 0
df%T_E["Economy" %in% df$theme] <- 1