我正在R中建立一个新项目,我需要从vector(Docs)中提取每个符号,我编写了这段代码,但是没有用
pattern=c("=d","<3",":o",":(",":)","(y)",":*","^_^",":d",";)",":'(")
for (value in docs) {
variable = sapply(value,function(x){
i = which(patt%in%strsplit(x," ")[[1]])
if (length(i)>0){
paste(pattern[i],collapse=" ")
} else{NA}
})
names(variable)=NULL
variable
}
答案 0 :(得分:0)
使用包stringr
和函数str_extract_all(Docs, 'symbol',simplify = TRUE)
可以找到所需的内容。
如果您是说每个字符strsplit(Docs, '')
就足够了。