densityplot

0th

Percentile

Kernel Probability Density Plots

Draw Kernel Density plots

Keywords
hplot
Usage
densityplot(formula, data, n = 50, plot.points = TRUE, ref = FALSE, ...)
Arguments
formula
A formula of the form ~ x | g1 * g2 * ... indicating that density plots of x should be produced conditional on the levels of the variables g1,g2,.... x must be numeric, and each of
data
data frame in which variables are to be evaluated.
n
number of points at which density is to be evaluated
plot.points
logical specifying whether the x values should be plotted.
ref
logical specifying whether a reference x-axis should be drawn.
...
arguments to be passed down to the panel function, in turn to be passed to density (if the default panel function is used).
Details

See the documentation for trellis.args for description of other valid arguments. The density estimate is actually calculated using the function density, and all arguments accepted by it can be passed (as ...) in the call to densityplot to control the output. See documentation of density for details. (Note: The default value of the argument n of density is changed to 50.)

Value

• An object of class trellis'', plotted by default by print.trellis.

synopsis

densityplot(formula, data = parent.frame(), aspect = "fill", layout = NULL, panel = panel.densityplot, prepanel = NULL, scales = list(), strip = TRUE, groups = NULL, xlab, xlim, ylab, ylim, bw = NULL, adjust = NULL, kernel = NULL, window = NULL, width = NULL, give.Rkern = FALSE, n = 50, from = NULL, to = NULL, cut = NULL, na.rm = NULL, ..., subscripts = !is.null(groups), subset = TRUE)

trellis.args, density, panel.densityplot, panel.mathdensity,Lattice

• densityplot
Examples
data(singer)
densityplot( ~ height | voice.part, data = singer, layout = c(2, 4),
xlab = "Height (inches)", bw = 5)
## Using a predefined panel function to fit a normal distribution
densityplot( ~ height | voice.part, data = singer, layout = c(2, 4),
xlab = "Height (inches)",
ylab = "Kernel Density/ Normal Fit",
main = list("Estimated Density", cex = 2, col = "DarkOliveGreen"),
panel = function(x, ...) {
panel.xyplot(x = jitter(x),
y = rep(0, length(x)))
panel.densityplot(x, ...)
panel.mathdensity(dmath = dnorm,
args = list(mean=mean(x),sd=sd(x)))
} )
Documentation reproduced from package lattice, version 0.3-1, License: GPL version 2 or later

Community examples

Looks like there are no examples yet.