powered by
Reads a data frame and line plots the selected variables (which need to be numeric) by group and an ordered factor (normally the time-series indicator).
prepare_by_group_trend_graph( df, ts_id, group_var, var, points = TRUE, error_bars = FALSE )
Data frame containing the ordered factor and a set of numerical variables to be plotted.
a string containing the column name of the ordered factor (normally the time-series indicator).
a variable coercible into a factor to group the data on.
The name of the variable that you want to plot.
Do you want points to indicate the observations? Defaults to TRUE.
TRUE
Do you want error bars to be plotted? Defaults to FALSE.
FALSE
A list containing two items:
A data frame containing the plotted means and standard errors by group
The plot as returned by ggplot
ggplot
# NOT RUN { df <- worldbank df$gdp_capita <- worldbank$NY.GDP.PCAP.KD graph <- prepare_by_group_trend_graph(df, "year", "region", "gdp_capita") graph$plot # }
Run the code above in your browser using DataLab