ts_plot

Description

Plots frequency of tweets as time series or, if multiple filters (text-based criteria used to subset data) are specified, multiple time series.

Usage

1
2
3
ts_plot(rt, by = "days", txt = "text", filter = NULL, exclude = NULL,
  key = NULL, cols = NULL, leg.x = NULL, leg.y = NULL, lab.cex = NULL,
  lwd = NULL, ...)

Arguments

rt

Tweets data frame

by

Unit of time, e.g., secs, days, weeks, months, years

txt

Name of text variable in data frame which filter is applied to.

filter

Vector of regular expressions with which to filter data (creating multiple time series)

exclude

Vector of regular expressions with which to distinguish data.

key

Labels for filters. Defaults to actual filters.

cols

Colors for filters

leg.x

Location for plot text

leg.y

Location for plot text

lab.cex

Size of filter labels

lwd

Width of filter lines

...

Arguments passed to plot function, e.g., main = "#rstats tweets", xlab = "Date", ylab = "Tweets", main.cex = 1.

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
## Not run: 
## stream tweets mentioning beibs and tswift for 10 mins
rt <- rtweet::stream_tweets(
    q = "justinbieber,taylorswift13",
    timeout = (60 * 60 * 10))

## split mentions into distinct elements
mentions <- strsplit(rt$mentions_screen_name, ",")

## sorted table of mentions
mentions <- sort(table(unlist(mentions)),
    decreasing = TRUE)

## exclude biebs and tswift
mentions <- grep("justinbieber|taylorswift13", names(mentions),
    invert = TRUE, value = TRUE)

## store next most pop in obj
thirdpop <- mentions[1]

##plot with mentions as filters
ts.df <- ts_plot(rt, by = "mins", filter = c(
    "justinbieber", "taylorswift", thirdpop),
    main = "Biebs vs Tswift")

## preview returned data frame
head(ts.df)


## End(Not run)