I am a beginner to R. I have 13 variables to combine into 1 variable.
I want to override the combined cell if an unrelated VariableX = a specific string, if so, the corresponding cell of the new variable should = the string.
I tried to do this together with an ifelse statement, but didn't really work:
Sectors <- paste0("sector", 1:13)
Combinedsectors <- combinedlocations %>% ifelse (Type.of.org != "Independent
Artist",
unite(Sector, Sectors, na.rm=TRUE, remove=TRUE), $Sector="Independent
Artist")
What I've done now is combine the sectors into one variable - is it better to just change that call after combining? If so, what would be the code for that?
This is the code I tried to use after first merging the columns:
combinedlocations$Sector = ifelse(combinedlocations$Type.Of.org="Independent
Artist" & !is.na(combinedlocations$Type.Of.org), "Independent Artist",
combinedlocations$Sector)
It gave me an error: Error: unexpected '=' in "combinedlocations$Sector = ifelse(combinedlocations$Type.Of.org="