histogram {r2spss} | R Documentation |
Histogram
Description
Draw a histogram of a variable in a data frame. The plot thereby mimics the look of SPSS graphs.
Usage
histogram(
data,
variable,
bins = NULL,
normal = FALSE,
normal.colour = NULL,
normal.color = NULL,
normal.linetype = NULL,
normal.size = NULL,
normal.alpha = NULL,
digits = 3,
limits = NULL,
expand = 0.05,
version = r2spss_options$get("version"),
...
)
Arguments
data |
a data frame containing the variable to be plotted. |
variable |
a character string specifying the variable to be plotted. |
bins |
an integer giving the number of bins for the histogram. |
normal |
a logical indicating whether to add a normal density with the
estimated mean and standard deviation (the default is |
normal.colour , normal.color , normal.linetype , normal.size , normal.alpha |
aesthetics for the normal density. In the unlikely event that both US and UK spellings of color are supplied, the US spelling will take precedence. |
digits |
an integer giving the number of digits after the comma to be printed in the summary statistics in the right plot margin. |
limits |
a list of arguments to be passed to
|
expand |
a numeric value specifying the percentage of the range to be
used for padding the axes. The default is 0.05 to expand the |
version |
a character string specifying whether the plot should mimic
the look of recent SPSS versions ( |
... |
additional arguments to be passed down, in particular
aesthetics (see |
Value
An object of class "ggplot"
, which produces
a histogram when printed.
Note
Due to the inner workings of this function to mimic the look
of histograms in SPSS, it is not expected that the user adds
scale_x_continuous
or
scale_y_continuous
to the plot. Instead, axis
limits and padding should be modified via the limits
and
expand
arguments.
Author(s)
Andreas Alfons
Examples
# load data
data("Eredivisie")
# log-transform market values
Eredivisie$logMarketValue <- log(Eredivisie$MarketValue)
# plot histogram of log market values
histogram(Eredivisie, "logMarketValue", normal = TRUE,
limits = list(x = c(9.5, 17.5)))