【问题标题】:trimws Function not Found - R未找到修剪功能 - R
【发布时间】:2017-04-24 07:10:44
【问题描述】:

我正在尝试使用 gtrends 包,但我不断收到以下错误:

dp <- gtrends("Donald Drumpf", res="7d")
Error in .processResults(resultsText, queryparams) : 
  could not find function "trimws"

这里是完整的代码:

library(gtrendsR)
dp <- gtrends("Donald Drumpf", res="7d")
plot(dp) + ggplot2::ggtitle("The Drumpf") + ggplot2::theme(legend.position="none")

您可能必须使用gconnect() 函数才能使其工作。

谢谢!

编辑:这是sessionInfo() 输出:

R version 3.1.3 (2015-03-09)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)

locale:
[1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252   
[3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C                      
[5] LC_TIME=Portuguese_Brazil.1252    

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

other attached packages:
[1] gtrendsR_1.3.3

loaded via a namespace (and not attached):
 [1] bitops_1.0-6     colorspace_1.2-4 ggplot2_2.0.0    googleVis_0.5.10
 [5] grid_3.1.3       gtable_0.1.2     lattice_0.20-30  munsell_0.4.2   
 [9] plyr_1.8.3       Rcpp_0.11.4      RCurl_1.95-4.5   RJSONIO_1.3-0   
[13] scales_0.3.0     tools_3.1.3      zoo_1.7-11  

【问题讨论】:

标签: r gtrendsr


【解决方案1】:

只是为了完整性。我用不同的 R 版本(低于 3.2 及更高版本)对其进行了测试。 R 低于 3.2 绝对是它不起作用的原因。 trimws 仅在更新的版本中可用。更新 R,它会工作。

请注意,谷歌可能会在一开始就阻止新机器。但是,一旦他们确信是您访问了该帐户,它就会起作用。

【讨论】:

    【解决方案2】:

    它对我有用。只需要删除 res='7d' dp <- gtrends("Donald Drumpf") plot(dp) + ggplot2::ggtitle("The Drumpf") + ggplot2::theme(legend.position="none") 这是我刚刚更新到最新 R 版本 3.4.0 (2017-04-21)Trump Trends

    的输出

    【讨论】:

      猜你喜欢
      • 2017-01-08
      • 2020-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-20
      • 1970-01-01
      • 1970-01-01
      • 2016-12-11
      相关资源
      最近更新 更多