As in the image below, how would I remove each of the 'year olds' from the second column?
CodePudding user response:
df$age5txt <- gsub(" year olds", "", df$age5txt)
where df
is your dataset
CodePudding user response:
Using trimws
df$age5txt <- trimws(df$age5txt, whitespace = "\\s year olds")