trend2long: extract_trend List Output to Long Format

Description Usage Arguments Value Note Examples

Description

Reshape a extract_trend list output to long format with a term colun added.

Coerce a data.frame to a trend2long object.

Usage

1
2
3

Arguments

x

An extract_trend list output.

...

Currently ignored.

Value

returns a data.frame of trend data by lookup terms.

Returns a a trend2long object.

Note

There is no object checking. It is the user's responsibility to make sure the object being coerced correspondes to a trend2long object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Not run: 
library(dplyr)
out <- gtrend_scraper("tyler.rinker@gmail.com", "password",
    c("ebola", "sars", "hiv", "aids", "influenza", "flu", "the cold"))

as.zoo.gtrends(out[[1]])

trend2long(out) %>%
   plot

library(dplyr)
trend2long(out) %>%
   filter(term %in% c("hiv", "ebola", "sars")) %>%
   as.trend2long %>%
   plot

library(ggplot2)
trend2long(out) %>%
    ggplot(aes(x=start, y=term, fill=trend)) +
    geom_tile() +
    scale_fill_gradient(low="black", high="white") +
    scale_x_date(expand = c(0, 0)) +
    theme_bw() + xlab("time")

## End(Not run)

trinker/gtrend documentation built on May 31, 2019, 8:43 p.m.