
Prepares a Quantile Trend Graph
Source:R/prepare_quantile_trend_graph.R
prepare_quantile_trend_graph.Rd
Reads a data frame and plots the quantiles of the specified variable by an ordered factor (normally the time-series indicator)
Arguments
- df
Data frame containing the ordered factor and the numerical variable to be plotted
- ts_id
a string containing the column name of the ordered factor (normally the time-series indicator)
- quantiles
a numerical vector containing the quantiles that are to be plotted
- var
a string containing the column name of the variable to be plotted. Defaults to the last numerical variable of the data frame that is not
ts_id
.- points
Do you want points to indicate the statistics? Defaults to
TRUE
.
Value
A list containing two items:
- "df"
A data frame containing the plotted quantiles
- "plot"
The plot as returned by
ggplot
Examples
prepare_quantile_trend_graph(worldbank, "year", var = "SP.DYN.LE00.IN")$plot +
ggplot2::ylab("Life expectancy at birth world-wide")
df <- data.frame(year = floor(stats::time(datasets::EuStockMarkets)),
DAX = datasets::EuStockMarkets[,"DAX"])
graph <- prepare_quantile_trend_graph(df, "year", c(0.05, 0.25, 0.5, 0.75, 0.95))
graph$plot