Make a bar plot of the variables in the given data frame, in a single plot area.

ggplot_ecodata_bar(
  data,
  variables = NULL,
  title = "",
  plot_at = "last",
  highlight = NULL,
  order = "descend",
  lowest = 0,
  highest = 0,
  ylab = NULL,
  fill = NULL,
  title_strlen = 60,
  variable_strlen = 35
)

Arguments

data

Data frame from `get_ecodata()` that includes the variables to plot

variables

Optional, vector of strings that includes the economic variables to plot. If not specified, the function will plot all the variables given in `data`, if possible.

title

Optional, string for the title of the plot. Default is ""

plot_at

Optional, string for what value to plot over the time series, can be one of the following: - "last" - Plot the last value in the time series - "first" - Plot the first value in the time series - "mean" - Plot the mean value in the time series - "median" - Plot the median value in the time series - "smallest" - Plot the smallest value in the time series - "largest" - Plot the largest value in the time series - A date string in the format "YYYY-MM-DD" - Plot the value at that date Default is "last"

highlight

Optional, string for the variable to highlight in the plot. Default is NULL

order

Optional, string for the order of the bars in the plot, can be one of the following: - "ascend" - Order the bars in ascending order - "descend" - Order the bars in descending order - "none" - Do not order the bars by the length of the bar. Will be either alphabetical, or in the order given in the `variables` parameter Default is "descend"

lowest

Optional, for plotting bars only for the lowest values. Select a value greater than 0 to choose this many bars. A value of 0 means this option will not be used. Can only pass values for `lowest` or `highest`, but not both. Default is 0.

highest

Optional, for plotting bars only for the highest values. Select a value greater than 0 to choose this many bars. A value of 0 means this option will not be used. Can only pass values for `lowest` or `highest`, but not both. Default is 0.

ylab

Optional, string for the label of the vertical axis. Default is NULL

fill

Optional, string, or vector of strings, for the color of the bars. Default is "dodgerblue4". If you want to highlight a variable, pass a vector of length 2. The first element is the color for the other bars, and the second element is the color for the highlighted variable.

title_strlen

Optional, integer for the maximum number of characters in the title before wrapping. Default is 60

variable_strlen

Optional, integer for the maximum number of characters in the variable names before wrapping. Default is 35

Value

A ggplot object with a bar plot of the variables in the given data frame