我得到了一组 Twitter 状态更新,我试图过滤后者的所有直接消息、发送者和接收者。我的数据框包括发件人和文本的列。使用正则表达式我正在尝试将接收者从文本列中过滤出来。
这就是我得到的,但它返回了一些奇怪的结果
WD <- getwd()
if (!is.null(WD)) setwd(WD)
load("data.R")
#http://www.unet.univie.ac.at/~a0406222/data.R
dmtext <- grep("^@[a-z0-9_]{1,15}", tweets$text, perl=T, value=TRUE,ignore.case=TRUE)
dm.receiver <- gsub("^@([a-z0-9_]{1,15})[ :,].*$", "\\1", dmtext, perl=T,ignore.case=TRUE)
dm.sender <- as.character(tweets$from_user[grep("^@[a-z0-9_]{1,15}", tweets$text, perl=T,ignore.case=TRUE,value=FALSE)])
dm.df <- data.frame(dm.sender,dm.receiver,dmtext)
dm.df[1:1000,2]
这些是我为 dm.receiver 得到的坏结果的一些例子
@insultaofuturo Apesar da proibição, jovens insistem em acampar no Aterro na Rio+20\nhttp://t.co/dCfFHUWV
@mqtodd Bringing the .green Internet to Rio+20 Summit | DotGreen\nhttp://t.co/pQqYilXp #RioPlus20 #gogreen
@Shyman33 Elinor Ostrom's trailblazing commons research can inspire Rio+20\n http://t.co/m7OTHBtP
@OccupyRio20 @pnud_es @FBuenAbad @rioplussocial #Futurewewant \nALGO DE ESTO SE HA CUMPLIDO? http://t.co/QDlVwT5z
@UNDP_CDG#UNDP#Asia-Pacific#Rio+20E-discussion on National&Local Planning for Sustainable Development. Contribute&mail:aprc.rio20@undp.org
为什么我使用 {1,15} 得到的结果超过 15 个字符?