Learn R Programming

loa (version 0.2.22)

2.1.specialist.panels: Special panel functions 01

Description

Specialist panel functions for use with lattice and loa plots.

Usage

panel.kernelDensity(x, y, z = NULL, ..., n = 20, 
         kernel.fun = NULL, panel.range = TRUE, 
         process = TRUE, plot = TRUE, loa.settings = FALSE)

panel.binPlot(x = NULL, y = NULL, z = NULL, 
         breaks=20, x.breaks = breaks, y.breaks = breaks,
         x1=NULL, x2=NULL, y1=NULL, y2=NULL,
         statistic = mean, pad.grid = FALSE, ...,
         plot = TRUE, process = TRUE, loa.settings = FALSE)

Arguments

x, y, z
lattice function arguments passed down to individual panels.
...
Additional arguments, typically passed on. See below.
n
For panel.kernelDensity, the number of x and y cases to estimate when estimating density.
kernel.fun
A function that can estimate kernel densities.
panel.range
For panel.kernelDensity, a logical (default FALSE) indicating if the kernel density estimation data range should be forced to the full panel range. See Below
process, plot, loa.settings
For panel... functions that intended to be handled using panelPal. process and plot, logicals, indicating if the process and plot sections of the panel
breaks, x.breaks, y.breaks
For panel.binPlot, how many break points to introduce when binning data. breaks can be used to use the same number of breaks on both axes, while x.breaks and y.breaks can be used to set thes
x1, x2, y1, y2
For panel.binPlot, vectors giving the bin cell dimensions used when binning x and y elements. Typically ignored and calculated within the plot call.
statistic
For panel.binPlot, the function to use when calculating z values for each set of binned. By default, this is mean. So, if a z element is supplied in the plot call, the data is binned accordin
pad.grid
For panel.binPlot, Logical, should empty bins be reported? If TRUE, they are reported as NAs; if FALSE, they are not reported.

Details

Some specialist panel... functions can be used be used with conventional lattice functions like xyplot, e.g.: xyplot(..., panel = panel.kernelDensity) xyplot(..., n = 50, panel = panel.kernelDensity) xyplot(..., panel = function(...) panel.kernelDensity(..., n = 50)) #etc} However, they are intended for use with panelPal. The combination provides a mechanism for the routine preprocessing of panel data, the association of specialist keys, and the routine alignment of panel and legend settings in cases where values are reworked within the panel function call. Typically, these are intended for use with panelPal, e.g.: loaPlot(..., panel = panel.kernelDensity) #etc} panel.kernelDensity generates kernel density estimations based on the supplied x and y data ranges. It ignores any supplied z information if supplied in the form: loaPlot(z~x*y, ..., panel = panel.kernelDensity) panel.binPlot bins supplied z data according to x and y values and associated break points (set by break arguments), and then calculates the required statistic for each of these. By default, this is mean, but alternative functions can be set using the statistic argument. if no z values are supplied, as in loaPlot(~x*y, ..., panel = panel.binPlot) ... panel.binPlot resets statistic to length and gives a count of the number of elements in each bin. These panel... functions As with other panel... functions in this package, output are suitable for use as the panel argument in loa (and sometimes lattice) plot calls. These function makes extensive use of code developed by others. lattice: Sarkar, Deepayan (2008) Lattice: Multivariate Data Visualization with R. Springer, New York. ISBN 978-0-387-75968-5 (for panel.kernelDensity) MASS package: Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer. [object Object] Both panel... functions can color both regions and lines. For panel.kernelDensity these are colored regions and contour lines separating them. For panel.binPlot these are the individual data bins and the borders surrounding them. In both cases the color scheme applied to the colored regions ares controlled by col.regions and the colors applied to the lines are controlled by col. panel.kernelDensity passes additional arguments on to the kernel.fun to estimate kerenel density and the lattice function panel.contourplot to generate the associated plot. If no kernel.fun is supplied in the panel call, the MASS function kde2d is used to estimate kernel density. panel.binPlot passes limited arguments on to lrect. In loa: panelPal In lattice: xyplot, panel.contourplot, lrect ## Example 1 ## Specialist kernel density panel example a <- rnorm(1000) b <- rnorm(1000) c <- rnorm(1000) xyplot(a~b, panel = panel.kernelDensity, at = 0:5*5) loaPlot(~a*b, panel = panel.kernelDensity) # Note 1: # at sets col.regions for the color surface, but, as this is calculated # in-panel, this is not known at time of call. So, you need to set when # using specialist panels with standard lattice plots. # (Same is ture for any panel where plot attributes that are set in-panel # and need to be known in all panels and keys for consistent output.) # loa panels include separate process and plot steps that panelPal can use # to track these. # Note 2: # By default, the panel ignores z data. # # compare: # loaPlot(c~a*b, panel = panel.kernelDensity) #where z term (c) ignored # loaPlot(c~a*b, panel = panel.kernelDensity, n=100) #finer surface resolution ## Example 2 ## Specialist bin plot panel example # By default, the panel bins supplied z case as mean # modify by supplying alternative as statistic loaPlot(c~a*b, panel = panel.binPlot) loaPlot(c~a*b, panel = panel.binPlot, statistic=max) # Note: # If z is not supplied, statistic defaults to length to give a count # # loaPlot(~a*b, panel = panel.binPlot) #where z term not supplied #etc. methods