[R] How to replace match words whith colum name of data frame?Hi--

2017-08-01 Thread Ek Esawi
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]]

[R] How to replace match words whith colum name of data frame?

2017-07-30 Thread Abraham Mathew
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

Re: [R] How to replace match words whith colum name of data frame?

2017-07-01 Thread Fox, John
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