I have a dataframe called data. One of its columns is data$activity.
data$activity = c("eat", "sing", "dance", "sing", "eat and shop", "shop", "drinks",...)
I wish to replace specific values within the data$activity column to "Companionship" (string), and these specific values are stored in the following vector:
leisure = c("eat", "drinks", "shop", "eat and shop")
I tried the following,
data$activity[data$activity== leisure] <- "Companionship"
#to replace values in the 'leisure' vector that are found in data$activity, with the string, 'Companionship'
But error is: Warning in data$activity == leisure : longer object length is not a multiple of shorter object length