trendecon to download Google Trends data: Problem with `mutate()` column `trend_data`

128 Views Asked by At

I'm using the trendecon package to download daily data from Google Trends. This package uses gtrendsr under the hood, but creates many requests to create daily data for long periods of time (by default, Google doesn't give you daily data unless your search is less than 9 months). The command "proc_keyword_init" downloads daily, weekly, and monthly data for a given term and a given region.

I have been using the package for a while successfully, but starting yesterday all of my searches yield an error:

Error: Problem with mutate() column trend_data. i trend_data = list(...). x missing value where TRUE/FALSE needed i The error occurred in row 1.

From other posts and pages I've found, this error is usually discussed when dealing with a dataset, but I haven't seen it discussed in a context like this where someone is downloading data.

I have tried reinstalling the trendecon package a couple of time, including with dependencies. I've also tried in three different versions of R across two computers, and I'm getting the same error. The error persists even when trying queries I had successfully used previously.

Here is an example of code and output:

library(trendecon)
proc_keyword_init("/m/0866r", "IR") # this downloads searches for the topic "weather" in Iran; topics are language-independent, [as you can see the top searches for this topic](https://trends.google.com/trends/explore?date=now%201-d&geo=IR&q=%2Fm%2F0866r&hl=en)

Output:

Error: Problem with `mutate()` column `trend_data`. i `trend_data = list(...)`. x missing value where TRUE/FALSE needed i The error occurred in row 1. Backtrace: 1. trendecon::proc_keyword_init("weather", "IR") 14. base::.handleSimpleError(...) 15. dplyr:::h(simpleError(msg, call))
18.
stop(fallback)
17.
signal_abort(cnd)
16.
abort(bullets, class = c("dplyr:::mutate_error", "dplyr_error"), error_name = error_name, error_expression = error_expression, parent = e, bullets = bullets)
15.
h(simpleError(msg, call))
14.
.handleSimpleError(function (e) { local_call_step(dots = dots, .index = i, .fn = "mutate", .dot_data = inherits(e, "rlang_error_data_pronoun_not_found")) ...
13.
FUN(X[[i]], ...)
12.
lapply(gtrendslist, get_ts_from_gtrends)
11.
ts_gtrends(keyword, category, geo, window, retry, wait, quiet)
10.
mask$eval_all_mutate(quo)
9.
withCallingHandlers({ for (i in seq_along(dots)) { mask$across_cache_reset() context_poke("column", old_current_column) ...
8.
mutate_cols(.data, ..., caller_env = caller_env())
7.
mutate.data.frame(., trend_data = list(ts_gtrends(keyword, category, geo, window, retry, wait, quiet)))
6.
mutate(., trend_data = list(ts_gtrends(keyword, category, geo, window, retry, wait, quiet)))
5.
unnest(., cols = trend_data)
4.
ungroup(.)
3.
tbl %>% mutate(trend_data = list(ts_gtrends(keyword, category, geo, window, retry, wait, quiet))) %>% unnest(cols = trend_data) %>% ungroup()
2.
ts_gtrends_windows(keyword = keyword, geo = geo, from = from, stepsize = "15 days", windowsize = "6 months", n_windows = floor(as.numeric(Sys.Date() - as.Date(from))/15), wait = 20, retry = 10, prevent_window_shrinkage = TRUE)
1.
proc_keyword_init("/m/0866r", "IR")
0

There are 0 best solutions below