podlove_plot_regression: Create a regression plot of episode downloads against an...

Description Usage Arguments Value Examples

View source: R/podlove_plot_regression.R

Description

Wrapper function to take data from podlove_get_and_clean() and creates a regression plot with several graphical options.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
podlove_plot_regression(
  df_tidy_data,
  point_in_time,
  time_unit = "days",
  predictor = post_datehour,
  plot_type = "line",
  label = FALSE,
  regline = TRUE,
  ribbon = TRUE,
  stylize = TRUE,
  print_model = TRUE,
  print_plot = TRUE
)

Arguments

df_tidy_data

a tidy table of downloads created by podlov_clean_stats() or podlove_get_and_clean()

point_in_time

Measurement point in time relative to episode release in hours or days. Can be a single value or a vector of integers.

time_unit

Time unit of points_in_time, either "days" (default) or "hours".

predictor

a single predictor variable for downloads, typically a time or order based variable such as post_date, post_datehour (default), episode_age_hours/episode_age_days (note: age decreases with episodes!) or episode_rank.

plot_type

the type of plot that should be generated. accepts a string from the list "point" (dot plot), "line" (line plot") or "area (area plot)

label

boolean switcher to label the plotted points with episode titles (default: FALSE)

regline

boolean switcher if the plot should contain a regression line (default: TRUE)

ribbon

boolean switcher if the plot should contain a confidence ribbon (default: TRUE)

stylize

boolean switcher if the plot should be beautifed (default TRUE). if FALSE, styling can be added later with + ggthemes::theme_name

print_model

boolean switcher if the regression model should be printed

print_plot

boolean switcher if the plot should print a graph

Value

a ggplot2 object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run: 
# prepare linear regression data for downloads on day 3 by episode release date
downloads <- podlove_create_example()

# create dot plot 
podlove_plot_regression(downloads, point_in_time = 3, plot_type = "point")

# create line plot with labels 
podlove_plot_regression(downloads, point_in_time = 3, plot_type = "point",
                         label = TRUE)

# create area plot without regression line and ribbon 
podlove_plot_regression(downloads, point_in_time = 3, predictor = post_datehour, 
                         plot_type = "point", regline = FALSE, ribbon = FALSE)

# create dot plot, add another theme 
podlove_plot_regression(downloads, point_in_time = 3, predictor = post_datehour, 
                        plot_type = "point", stylize = FALSE) +
    ggthemes::theme_economist()

## End(Not run)

lordyo/podlover documentation built on Feb. 20, 2020, 5:58 p.m.