densityPlot {car} | R Documentation |
densityPlot
contructs and graphs nonparametric density estimates, possibly conditioned on a factor.
It is a wrapper for the standard R density
function.
densityPlot(x, ...)
## Default S3 method:
densityPlot(x, g, bw = "SJ", adjust=1,
kernel = c("gaussian", "epanechnikov", "rectangular",
"triangular", "biweight", "cosine", "optcosine"),
xlab = deparse(substitute(x)), ylab = "Density", col = palette(),
lty = seq_along(col), lwd = 2, grid=TRUE,
legend.location = "topright", legend.title = deparse(substitute(g)),
show.bw = FALSE, rug = TRUE, ...)
## S3 method for class 'formula'
densityPlot(formula, data = NULL, subset, na.action = NULL, xlab, ylab, ...)
x |
a numeric variable, the density of which is estimated. |
g |
an optional factor to divide the data. |
formula |
an R model formula, of the form |
data |
an optional data frame containing the data. |
subset |
an optional vector defining a subset of the data. |
na.action |
a function to handle missing values; defaults to the value of the R |
bw |
the bandwidth for the density estimate(s); either the quoted name of a rule to
compute the bandwidth, or a numeric value; the default is |
adjust |
a multiplicative adjustment factor for the bandwidth; the default, |
kernel |
kernel function; the default is "gaussian" (see |
xlab |
label for the horizontal-axis; defaults to the name of the variable |
ylab |
label for the vertical axis; defaults to |
col |
vector of colors for the density estimate(s); defaults to the color |
lty |
vector of line types for the density estimate(s); defaults to the successive integers, starting at 1. |
lwd |
line width for the density estimate(s); defaults to 2. |
grid |
if |
legend.location |
location for the legend when densities are plotted for several groups; defaults to
|
legend.title |
label for the legend, which is drawn if densities are plotted by groups; the default is the name of the factor g. |
show.bw |
if |
rug |
if |
... |
arguments to be passed to |
These functions return NULL
invisibly and draw graphs.
John Fox jfox@mcmaster.ca
W. N. Venables and B. D. Ripley (2002) Modern Applied Statistics with S. New York: Springer.
density
, bw.SJ
, link{plot.density}
densityPlot(~ income, show.bw=TRUE, data=Prestige)
densityPlot(income ~ type, data=Prestige)