无法在tm中找到content_transformer

时间:2016-06-18 07:48:31

标签: r data-mining tm text-analysis

是否从tm包0.6-2中删除了content_transformer函数

library(tm)
docs<-Corpus(DirSource("Dname"))
docs<-tm_map(docs,content_transformer(gsub), pattern="using",replacement="use")
Error: could not find function "content_transformer" 

1 个答案:

答案 0 :(得分:1)

您可能需要更新包。 This GitHub repository表示该函数已导出,也是present in the code

> library(tm)
Loading required package: NLP
> content_transformer
function (FUN) 
function(x, ...) {
    content(x) <- FUN(content(x), ...)
    x
}
<environment: namespace:tm>

> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=Slovenian_Slovenia.1250  LC_CTYPE=Slovenian_Slovenia.1250    LC_MONETARY=Slovenian_Slovenia.1250
[4] LC_NUMERIC=C                        LC_TIME=Slovenian_Slovenia.1250    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] tm_0.6-2  NLP_0.1-9

loaded via a namespace (and not attached):
[1] rsconnect_0.4.1.4 parallel_3.2.3    tools_3.2.3       slam_0.1-35