Abraham Mathew
2017-Jul-30 21:06 UTC
[R] How to replace match words whith colum name of data frame?
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_dfconcept match 1 butan acid chemical 2 nano diamond particl FALSE 3 slurri\ncomposit FALSE 4 composit ph polis chemical 5 inorgan particl FALSE 6 grind liquid FALSE 7 liquid formul FALSE 8 nanoparticl FALSE 9 size abras particl FALSE 10 agent malic acid chemical -- *Abraham MathewData Ninja and Statistical Modeler* *Minneapolis, MN720-648-0108 at abmathewksAnalytics_Blog <mathewanalytics.wordpress.com>* [[alternative HTML version deleted]]