Hi--
concept_df$NewCol <- "";
kw <- "acid|ph";
bb <- grepl(kw,concept_df$concept)
concept_df[dd,2] <- "chemical"
The is a bit late but it accomplish the same with base R.
Good luck--EK
PS.. my email doesn't accept reply
[[alternative HTML version deleted]]
Try the stringr package.
This should work
chemical=c("basic", "alkalin", "alkali", "acid", " ph ", "hss")
chemical_match <- str_c(chemical, collapse = "|")
chemical_match
concept_df$match[str_detect(concept_df$concept, chemical_match)] <-
"chemical"
concept_df
> concept_df
ginal Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of ? ”
> Sent: Saturday, July 1, 2017 3:44 AM
> To: r-help@r-project.org
> Subject: [R] How to replace match words whith colum name of data frame?
>
> I have two data frame. I want to use "chemical_df
3 matches
Mail list logo