r - Using regex and subset to extract a subset of a data frame -


i have 1 column inside dataframe contains different kinds of text within it, example follows:

column                 column b               column c kuala lumpur 2 new        7                      old jakarta 3             6                      c 7 hong kong               3                      jakarta new 22            2                      b 

my goal extract rows of dataframe corresponding word 'jakarta' somewhere in aforementioned column. imagine regex capable of finding word, not sure how 1 combine extract info via subset. note sheet large, prefer use command subset rather loop if possible. desired output be:

column                 column b               column c old jakarta 3             6                      c jakarta new 22            2                      b 

many in advance help

you grepl

data

df <- data.frame(columna=c("kuala lumpur 2 new", "old jakarta 3", "7 hong kong", "jakarta new 22"),              columnb=c(7, 6, 3, 2), columnc=c("a", "c", "a", "b")) 

code

df[grepl("jakarta ", df$columna), ] 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -