scatter_plot | R Documentation |
Draw a scatter plot or a scatter plot matrix of variables in a data frame. The plots thereby mimic the look of SPSS graphs.
scatter_plot(data, variables, version = r2spss_options$get("version"), ...)
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 x-axis and the second variable on the y-axis. In case of more than two variables, a scatter plot matrix is produced. |
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 |
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.
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.
Andreas Alfons
# 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"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.