plot_summary: Generate summary plot

Description Usage Arguments Value Examples

View source: R/plot_summary.R

Description

Create a horizontal bar chart summarizing a specified variable and value within a time period

Usage

1
2
3
4
5
6
7
8
9
plot_summary(
  df,
  var = "location",
  val = "new_cases",
  fun = "sum",
  date_from = NULL,
  date_to = NULL,
  top_n = 5
)

Arguments

df

Data frame of the selected covid data from get_data()

var

Qualitative values to segment data. Must be a categorical variable. Also known as a 'dimension'. By default 'location'

val

Quantitative values to be aggregated. Must be numeric variable. Also known as a 'measure'. By default 'new_cases'

fun

Aggregation function for val, by default 'sum'

date_from

Start date of the data range with format 'YYYY-MM-DD'. By default 'NULL' is used to represent 7 days prior to today's date

date_to

End date of data range with format 'YYYY-MM-DD'. By default 'NULL' is used to represent today's date

top_n

Specify number of qualitative values to show, by default 5

Value

ggplot chart object

Examples

1
2
3
4
5
6
df <- get_data(date_from = "2022-01-01", date_to = "2022-01-07")
plot_summary(
  df,
  var = "location", val = "new_cases", fun = "sum",
  date_from = "2022-01-01", date_to = "2022-01-13", top_n = 5
)

UBC-MDS/covizr documentation built on Feb. 7, 2022, 9:11 a.m.