line_plot {r2spss}R Documentation

Line Plots

Description

Draw connected lines for variables in a data frame. The plot thereby mimics the look of SPSS graphs.

Usage

line_plot(
  data,
  variables,
  index = NULL,
  version = r2spss_options$get("version"),
  ...
)

Arguments

data

a data frame containing the variables to be plotted.

variables

a character vector specifying at least one variable to be plotted on the y-axis. In case of multiple variables, separate lines are drawn for each variable and a legend is shown.

index

a character string specifying a variable to be plotted on the x-axis, or NULL to plot the observations against their index.

version

a character string specifying whether the plot should mimic the look of recent SPSS versions ("modern") or older versions (<24; "legacy").

...

additional arguments to be passed down to geom_line.

Value

An object of class "ggplot", which produces a line plot when printed.

Author(s)

Andreas Alfons

Examples

# load data
data("Eredivisie")
# log-transform market values
Eredivisie$logMarketValue <- log(Eredivisie$MarketValue)

# aggregate log market values by position
means <- aggregate(Eredivisie[, "logMarketValue", drop = FALSE],
                   Eredivisie[, "Position", drop = FALSE],
                   FUN = mean)

# create profile plot
line_plot(means, "logMarketValue", "Position")

# easier and fancier as the plot method of ANOVA results
oneway <- ANOVA(Eredivisie, "logMarketValue",
                group = "Position")
plot(oneway)


[Package r2spss version 0.3.2 Index]