Closed agilebean closed 6 years ago
Looking at your first graph, it seems that Y values are factors or strings.
why would anything different happen if i pass the search terms exactly in the same fashion by c("a","b","c")?
So I have a different hunch for the root cause: If a search term has average hits around 1, the plot() function switches to horizontal line plot. This must be a condition which could be changed, can't it?
No, it is because the returned data was parsed as text instead of numeric because of the <1
value. You can convert the vector to numeric and plot it again.
That makes a lot of sense. Thanks for the tip! Any chance this conversion will be integrated into the plot function?
I will figure it out, but so far, this try didn't work:
social.life <- gtrends(c("talk", "conversation", "smartphone")) %T>% plot
social.life$hits <- social.life %>% .[[1]] %>% .$hits %>%
lapply(function(x) if (x=="<1") x <- 0 else x) %>%
as.numeric()
library(gtrendsR)
social.life <- gtrends(c("talk", "conversation",
"smartphone overuse"))
#> Warning in is.na(object): is.na() applied to non-(list or vector) of type
#> 'NULL'
#> Warning in is.na(object): is.na() applied to non-(list or vector) of type
#> 'NULL'
#> Warning in is.na(object): is.na() applied to non-(list or vector) of type
#> 'NULL'
#> Warning in is.na(object): is.na() applied to non-(list or vector) of type
#> 'NULL'
#> Warning in is.na(object): is.na() applied to non-(list or vector) of type
#> 'NULL'
#> Warning in is.na(object): is.na() applied to non-(list or vector) of type
#> 'NULL'
#> Warning in is.na(object): is.na() applied to non-(list or vector) of type
#> 'NULL'
#> Warning in is.na(object): is.na() applied to non-(list or vector) of type
#> 'NULL'
#> Warning in is.na(object): is.na() applied to non-(list or vector) of type
#> 'NULL'
#> Warning in is.na(object): is.na() applied to non-(list or vector) of type
#> 'NULL'
#> Warning in is.na(object): is.na() applied to non-(list or vector) of type
#> 'NULL'
social.life$interest_over_time$hits <- as.numeric(social.life$interest_over_time$hits)
#> Warning: NAs introduced by coercion
plot(social.life)
#> Warning: Removed 2 rows containing missing values (geom_path).
Created on 2018-03-12 by the reprex package (v0.2.0).
Ah - the $hits was within the interest_over_time object... Thanks a lot!!
For the last few weeks, the plot function does not show the expected result any more. Is this related to Google API changes? Would be grateful for a fix!
renders
instead of a line plot.
interesting: for some reason, this seems to depend on the search terms! this works:
gives - as expected - this line plot: