podlove_plot_curves: Plot Download Curves from Download Data

Description Usage Arguments Value See Also Examples

View source: R/podlove_plot_curves.R

Description

Wrapper function to prepare and generate a line curve diagram of downloads over time. It takes an optional grouping variable (e.g. title) as well as options for the time axis of downloads for cumulative display, labeling and print output. If you want to generate and tweak the data behind this plot, use podlove_prepare_stats_for_graph.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
podlove_plot_curves(
  dldata,
  gvar = "Total",
  time_unit = "days",
  relative = TRUE,
  cumulative = TRUE,
  plot_type = "line",
  labelmethod = "last.points",
  printout = TRUE,
  last_n = 0,
  sum_fun = NULL,
  limit = TRUE,
  legend = FALSE,
  ...
)

Arguments

dldata

A tidy data frame with download data, as constructed by podlove_prepare_stats_for_graph()

gvar

Optional grouping parameter (e.g. episode title), handed over to ggplot2::aes(color).

relative

Boolean switching parameter to define if the data is rendered relative to the respective episode release date (TRUE) or in absolute dates (TRUE). Defaults to TRUE.

cumulative

Boolean switch to show either cumulative data (TRUE, default), or non-comulative data (FALSE)

plot_type

Sets the plot type to either line plot ("line") or ridgeline plot ("ridge").

labelmethod

Defines where should the labels be attached (at the beinning of the curves: "last.points", default, or at the end of the curves "first.points")

printout

Switcher to automatically print out the plot (default TRUE)

last_n

Number of most recent episodes to filter for. Defaults to 0 (no filtering), use negative numbers to filter for first n episodes.

sum_fun

Summary function used to draw a (smoothed) curve over all gvar curves, e.g. mean or median. The summary is taken from all curves in the dataset, even if a last_n parameter is set. Do not quote.

limit

Boolean switch to fix axis limtis (relevant when adding smoothers)

...

additional formating parameters for ggplot2::geom_line() or ggridges::geom_density_ridges. Also used for depreciated arguments.

hourly

Boolean switching parameter for rendering of hourly vs. daily data. Defaults to FALSE (daily data), TRUE creates hourly data.

Value

A ggplot object

See Also

podlove_graph_download_curves(), podlove_prepare_stats_for_graph()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# create example data
dls <- podlove_create_example(clean = TRUE)

podlove_plot_curves(dls, gvar = title, relative = TRUE, cumulative = TRUE)

# add a mean curve
podlove_plot_curves(dls, gvar = title, relative = TRUE, cumulative = TRUE,
                    sum_fun = mean)
     
# show only the last 4 episodes' curves. Note how the summary curve remains 
# the same as in the plot before.
podlove_plot_curves(dls, gvar = title, relative = TRUE, cumulative = TRUE,
                    sum_fun = mean, last_n = 4)


# see podlove_graph_download_curves() for additional information.

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