Description Usage Arguments Author(s) See Also Examples
Compute kernel density plots, written in the same structure as boxPlot
. Histograms can be automatically added for teaching purposes.
1 2 3 4 5 6 7 8 9 | densityPlot(x, fact = NULL, bw = "nrd0",
histo = c("none", "faded", "hollow"),
breaks = "Sturges", fading = "0E", fadingBorder = "25",
lty = NULL, lwd = 1, col = c("black", "red", "blue"),
key = NULL, add = FALSE, adjust = 1,
kernel = c("gaussian", "epanechnikov", "rectangular",
"triangular", "biweight", "cosine", "optcosine"),
weights = NULL, n = 512, from, to, na.rm = FALSE,
xlim = NULL, ylim = NULL, main = "", ...)
|
x |
A numerical vector. |
fact |
A character or factor vector defining the grouping for data in |
bw |
Bandwidth. See |
histo |
Whether to plot a faded histogram ( |
breaks |
The |
fading |
Character value of hexadecimal, e.g. |
fadingBorder |
Character value of hexadecimal, e.g. |
lty |
Numerical vector describing the line type for the density curve(s). Each element corresponds to a different level of the argument |
lwd |
Numerical vector describing the line width for the density curve(s). Each element corresponds to a different level of the argument |
col |
Numerical vector describing the line color for the density curve(s). Each element corresponds to a different level of the argument |
key |
An argument to specify ordering of the factor levels. |
add |
If |
adjust |
Argument passed to |
kernel |
Argument passed to |
weights |
Argument passed to |
n |
Argument passed to |
from |
Argument passed to |
to |
Argument passed to |
na.rm |
Argument passed to |
xlim |
x-axis limits. |
ylim |
y-axis limits. |
main |
Title for the plot. |
... |
If |
David Diez
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | data(tips)
par(mfrow=c(2,2))
histPlot(tips$tip[tips$day == 'Tuesday'], hollow=TRUE, xlim=c(0, 30),
lty=1, main='Tips by day')
histPlot(tips$tip[tips$day == 'Friday'], hollow=TRUE, border='red',
add=TRUE, main='Tips by day')
legend('topright', col=c('black', 'red'), lty=1:2,
legend=c('Tuesday', 'Friday'))
densityPlot(tips$tip, tips$day, col=c('black', 'red'), main='Tips by day')
legend('topright', col=c('black', 'red'), lty=1:2,
legend=c('Tuesday', 'Friday'))
data(run10)
densityPlot(run10$time, histo='faded', breaks=15, main='Run time')
densityPlot(run10$time, histo='hollow', breaks=30, fadingBorder='66',
lty=1, main='Run time')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.