首页 > 解决方案 > Google 趋势函数中未使用的参数 (R)

问题描述

我正在尝试检索 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",
)

我已尝试按照其他帖子的建议包含“...”,并修改了函数的参数,但我没有找到任何应​​该包含这样一个参数的地方。

先感谢您!!

标签: rgoogle-trends

解决方案


你最后多了一个逗号。加:它必须是:(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")

就像这里建议的那样: R strptime/as.POSIXct 中的未知时区名称


推荐阅读