scatter_plot {r2spss} | R Documentation |
Scatter Plot and Scatter Plot Matrix
Description
Draw a scatter plot or a scatter plot matrix of variables in a data frame. The plots thereby mimic the look of SPSS graphs.
Usage
scatter_plot(data, variables, version = r2spss_options$get("version"), ...)
Arguments
data |
a data frame containing the variables to be plotted. |
variables |
a character vector specifying at least two variables to be
plotted. In case of two variables, a simple scatter plot is produced with
the first variable on the |
version |
a character string specifying whether the plot should mimic
the look of recent SPSS versions ( |
... |
for a simple scatter plot, additional arguments are passed
down to |
Value
In case of a simple scatter plot, an object of class
"ggplot"
, which produces the plot when printed.
In case of a scatter plot matrix, nothing is returned but a plot is produced.
Note
Wile all other plots in r2spss are based on ggplot2 (including the simple scatter plot), the scatter plot matrix is built around base R graphics. This is because ggplot2 does not provide an implementation of a scatter plot matrix, and an implementation based on separate scatter plots on a matrix layout would be slow.
Author(s)
Andreas Alfons
Examples
# load data
data("Eredivisie")
# log-transform market values
Eredivisie$logMarketValue <- log(Eredivisie$MarketValue)
# plot log market values against age
scatter_plot(Eredivisie, c("Age", "logMarketValue"))
# scatterplot matrix of age, number of minutes played, and
# log market values
scatter_plot(Eredivisie, c("Age", "Minutes", "logMarketValue"))