Make a interaction line plot

interaction_line_plot(y, x, by, data, ylim = NULL, xlab = NULL, ylab = NULL)

Arguments

y

A continuous variable to be plotted along the y-axis

x

A continuous variable to be plotted along the x-axis

by

A categorical variable by which we split the data and create one line plot for each resulting group

data

A data frame with the x, y, by variables

ylim

A vector of limits for the y-axis

xlab

The label of the x-axis (defaults to the x variable name).

ylab

The label of the y-axis (defaults to the y variable name).

Value

A ggplot2::ggplot object, which may be modified with further ggplot2 commands.

Examples

interaction_line_plot(y = score, x = time, by = treatment, 
                      data = selfesteem2_long, ylim = c(70, 100))

interaction_line_plot(y = score, x = time, by = treatment, 
                      data = selfesteem2_long, 
                      xlab = 'measurement time',
                      ylab = 'self esteem score',
                      ylim = c(70, 100))