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
Post a Comment