| histogram | R Documentation |
Draw a histogram of a variable in a data frame. The plot thereby mimics the look of SPSS graphs.
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"),
...
)
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 x-axis by 5% on both sides and the y-axis by 5% on the upper end. Note that there is no padding on lower end of the y-axis to mimic SPSS behavior. |
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 |
An object of class "ggplot", which produces
a histogram when printed.
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.
Andreas Alfons
# 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)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.