plotHist | R Documentation |
Plot a histogram and a density plot of a single variable using the R-package lattice.
plotHist( x, HD = "over", nint = 20, digits = 2, stats = TRUE, BoxCox = FALSE, col = c("lightgray", "black"), lwd = c(1, 1), lty = "dashed", xlim, ylim, ... ) plotHD( x, HD = "over", nint = 20, digits = 2, stats = TRUE, BoxCox = FALSE, col = c("lightgray", "black"), lwd = c(1, 1), lty = "dashed", xlim, ylim, ... )
x |
Vector of numeric values of the variable for which the histogram and density plot should be created. |
HD |
Character value indicating the type of plot to be created. Available options are
|
nint |
Integer specifying the number of histogram bins. Defaults to |
digits |
Integer indicating the number of decimal places to be used
when printing the statistics of the variable |
stats |
Logical to indicate if descriptive statistics of the variable |
BoxCox |
Logical to indicate if the variable |
col |
Vector of two elements, the first indicating the color of the histogram, the second
indicating the color of the density plot. Defaults to |
lwd |
Vector of two elements, the first indicating the line width of the histogram, the
second indicating the line width of the density plot. Defaults to |
lty |
Character value indicating the line type for the density plot. Defaults to
|
xlim |
Vector of two elements defining the limits of the x axis. The function automatically
optimizes |
ylim |
Vector of two elements defining the limits of the y axis. The function automatically
optimizes |
... |
Other arguments that can be passed to lattice functions. There is no guarantee that they will work. |
The user should visit the help pages of lattice::histogram()
, lattice::densityplot()
,
lattice::panel.mathdensity()
, car::powerTransform()
, and car::bcPower()
to obtain more
details about the main functions used to built plotHD()
.
An object of class "trellis"
. The lattice::update.trellis()
method can be used to update
components of the object and the lattice::print.trellis()
print method (usually called by
default) will plot it on an appropriate plotting device.
The car package, provider of functions to accompany Fox and Weisberg's An R Companion to
Applied Regression, is required for plotHist()
to work. The development version of
the car package is available on https://r-forge.r-project.org/projects/car/ while its old
versions are available on the CRAN archive at
https://cran.r-project.org/src/contrib/Archive/car/.
Alessandro Samuel-Rosa alessandrosamuelrosa@gmail.com
Sarkar, Deepayan (2008) Lattice: Multivariate Data Visualization with R, Springer. http://lmdvr.r-forge.r-project.org/
lattice::histogram()
, lattice::densityplot()
, lattice::panel.mathdensity()
if (all(c(require(car), require(lattice), require(latticeExtra)))) { x <- rnorm(100, 10, 2) p1 <- plotHist(x, HD = "stack") p2 <- plotHist(x, HD = "over") }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.