boxPlot
. Histograms can be automatically added for teaching purposes.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
.density
.'faded'
) or hollow histogram ('hollow'
) in the background. By default, no histogram will be plotted.breaks
argument for histPlot if histo
is 'faded'
or 'hollow'
.'22'
or '5D'
, describing the amount of fading inside the rectangles of the histogram if histo='faded'
.'22'
or '5D'
, describing the amount of fading of the rectangle borders of the histogram if histo
is 'faded'
or 'hollow'
.fact
.fact
.fact
.TRUE
, the density curve is added to the plot.density
to adjust the bandwidth.density
to select the kernel used.density
to weight observations.density
to specify the detail in the density estimate.density
specifying the lowest value to include in the density estimate.density
specifying the largest value to include in the density estimate.density
specifying handling of NA
values.add=FALSE
, then additional arguments to plot
.histPlot
, dotPlot
, boxPlot
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')
Run the code above in your browser using DataLab