简体   繁体   English

使用gtrendsR的日期出错

[英]Error with date using gtrendsR

Why the code below works just fine: 为什么下面的代码工作得很好:

library(gtrendsR)

ch <- gconnect("usr@gmail.com", "psw")

query1 <- gtrends(query = c("Ludwig von Mises", "John Maynard Keynes", "Karl Marx"),
                 geo = c("BR"),
                 start_date = "2016-01-01",
                 end_date = "2016-03-31")

But if I change the date to: 但是,如果我将日期更改为:

query2 <- gtrends(query = c("Ludwig von Mises", "John Maynard Keynes", "Karl Marx"),
                 geo = c("BR"),
                 start_date = "2010-01-01",
                 end_date = "2016-03-31")

R trows an error: R出错:

Error in as.POSIXlt.character(x, tz, ...) : 
  character string is not in a standard unambiguous format

I live in Brazil. 我住在巴西。 The package seems not to handle the time-zone correctly if I do: 如果我这样做,包似乎不能正确处理时区:

Sys.setenv(LANG = "en", TZ = 'GMT')

before i run the code, it works. 在我运行代码之前,它可以工作。

If I enter the debug the problem is on the function 如果我进入调试问题就在函数上

.processResults(resultsText, queryparams) 

on the line 在线上

weeks <- lapply(weeks, as.POSIXct, SIMPLIFY = FALSE)

if I change to 如果我改变

weeks <- lapply(weeks, as.POSIXct, SIMPLIFY = FALSE, tz = 'GMT')

it also works. 它也有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM