您好:我使用tm软件包进行一些文本分析,并且我需要用向量中的配对替换项更换。所以模式/替换字典看起来像这样。使用mapply来替换矢量中的模式替换tm中的矢量
#pattern -replacement dictionary
df<-data.frame(replace=c('crude', 'oil', 'price'), with=c('xcrude', 'xoil', 'xprice'))
#load tm
library(tm)
#load crude
data('crude')
我尝试这样做,收到错误
tm_map(crude, mapply, gsub, df$replace, df$with)
Warning message:
In mclapply(content(x), FUN, ...) :
all scheduled cores encountered errors in user code
您是否必须使用'tm'来做到这一点? – Sotos
基本上可以。我很确定我可以在它之外做到这一点,但我想知道如何在tm中做到这一点。 – spindoctor