【问题标题】:Unused argument in Google Trends funcion (R)Google 趋势函数中未使用的参数 (R)
【发布时间】:2020-12-14 11:53:21
【问题描述】:

我正在尝试检索 Google 趋势查询,但收到以下错误:

Error in gtrends(keyword = "hotel zypern", geo = "DE", time = "2004-01-01 2016-04-30",  : 
  unused argument (alist())

我用 R 写的代码:

ger1<-gtrends(
  keyword = "hotel zypern",
  geo = "DE",
  time ="2004-01-01 2016-04-30",
  gprop = c("web", "news", "images", "froogle", "youtube"),
  category = "0",
  hl = "de",
  low_search_volume = FALSE,
  cookie_url = "http://trends.google.com/Cookies/NID",
  tz = "Europe/Berlin",
  onlyInterest = "FALSE",
)

我已尝试按照其他帖子的建议包含“...”,并修改了函数的参数,但我找不到任何应该包含此类参数的地方。

提前谢谢你!!

【问题讨论】:

    标签: r google-trends


    【解决方案1】:

    你最后多了一个逗号。另外:必须是:onlyInterest = FALSE(没有分号,它不是字符串,而是布尔值):

    ger1<-gtrends(
        keyword = "hotel zypern",
        geo = "DE",
        time ="2004-01-01 2016-04-30",
        gprop = c("web", "news", "images", "froogle", "youtube"),
        category = "0",
        hl = "de",
        low_search_volume = FALSE,
        cookie_url = "http://trends.google.com/Cookies/NID",
        tz = "Europe/Berlin",
        onlyInterest = FALSE
    )
    

    我收到了一个警告,但它有效。如果您想避免这种情况,请尝试设置您的 sys.setenv:

    Sys.setenv(TZ="Europe/Berlin")
    

    就像这里建议的那样: unknown timezone name in R strptime/as.POSIXct

    【讨论】:

      【解决方案2】:

      您在调用结束时有一个尾随逗号,暗示另一个参数。删除它即可解决该错误。

      ger1<-gtrends(
        keyword = "hotel zypern",
        geo = "DE",
        time ="2004-01-01 2016-04-30",
        gprop = c("web", "news", "images", "froogle", "youtube"),
        category = "0",
        hl = "de",
        low_search_volume = FALSE,
        cookie_url = "http://trends.google.com/Cookies/NID",
        tz = "Europe/Berlin",
        onlyInterest = "FALSE"
      )
      

      您还需要注意传递给函数的参数类别,例如 onlyInterest 正在寻找布尔值 (FALSE),而不是字符串 ("FALSE")。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-03-14
        • 1970-01-01
        相关资源
        最近更新 更多