r - Delete rows in Data table -


i have twitter dataset , delete whole row if word lee in tweet. have code, still same amount of entries.

dt.cleaned <- dt.tweets.filtered[body != "lee",] 

what code need in order remove whole row if word lee in body?

thank much!!

we can use grep

dt.cleaned <- dt.tweets.filtered[!grepl("lee", body)] 

assuming 'dt.tweets.filtered' data.table object. if data.frame, either convert data.table setdt i.e. setdt(dt.tweets.filtered) or use base r methods,

dt.cleaned <- dt.tweets.filtered[!grepl("lee", body), ] 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -