Skip to content

R help

1 message · Jim Lemon

#
Hi Vladimir,
This may fix the NA problem:

vdat<-read.table(text="numberoftweet,tweet,locations,badwords
1,My cat is asleep,London,glum
2,My cat is flying,Paris,dashed
3,My cat is dancing,Berlin,mopey
4,My cat is singing,Rome,ill
5,My cat is reading,Budapest,sad
6,My cat is eating,Amsterdam,annoyed
7,My cat is hiding,Copenhagen,crazy
8,My cat is fluffy,Vilnius,terrified
9,My cat is annoyed,Athens,sick
10,My cat is exercising,Ankara,mortified
11,My cat is dreaming,Kracow,irked
12,My cat is mopey,Vienna,uneasy
13,My cat is glum,Brussels,upset
14,My cat is swinging,Madrid,
15,My cat is crazy,Ljubljana,",
sep=",",header=TRUE,stringsAsFactors=FALSE)

vdat$badwords[!nchar(vdat$badwords)]<-NA

badwords<-paste(vdat$badwords[!is.na(vdat$badwords)],collapse="|")

names(unlist(sapply(vdat$tweet,grep,pattern=badwords)))

Jim
On Sun, Aug 7, 2016 at 6:43 PM, ???? ????????? <v.grabarnik at gmail.com> wrote: