ts_plot: Plots tweets data as a time series-like data object.

Description Usage Arguments Value Examples

View source: R/ts_plot.R

Description

Creates a ggplot2 plot of the frequency of tweets over a specified interval of time.

Usage

1
ts_plot(data, by = "days", trim = 0L, ...)

Arguments

data

Data frame or grouped data frame.

by

Desired interval of time expressed as numeral plus one of "secs", "mins", "hours", "days", "weeks", "months", or "years". If a numeric is provided, the value is assumed to be in seconds.

trim

The number of observations to drop off the beginning and end of the time series.

...

Other arguments passed to geom_line.

Value

If ggplot2 is installed then a ggplot plot 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
26
27
28
29
30
31
32
## Not run: 

## search for tweets containing "rstats"
rt <- search_tweets("rstats", n = 10000)

## plot frequency in 1 min intervals
ts_plot(rt, "mins")

## plot multiple time series--retweets vs non-retweets
rt %>%
  dplyr::group_by(is_retweet) %>%
  ts_plot("hours")

## compare account activity for some important US political figures
tmls <- get_timeline(
  c("SenSchumer", "SenGillibrand", "realDonaldTrump"),
  n = 3000
)

## examine all twitter activity using weekly intervals
ts_plot(tmls, "weeks")

## group by screen name and plot each time series
ts_plot(dplyr::group_by(tmls, screen_name), "weeks")

## group by screen name and is_retweet
tmls %>%
  dplyr::group_by(tmls, screen_name, is_retweet) %>%
  ts_plot("months")


## End(Not run)

rtweet documentation built on Nov. 17, 2017, 5:54 a.m.