prepanel.robust.y: Robust prepanel function for lattice plots (ylim).

View source: R/prepanel-robust-functions.R

prepanel.robust.yR Documentation

Robust prepanel function for lattice plots (ylim).

Description

This prepanel function can provide useful scales even if there is only one data point or if all values are identical (no variability). A limit parameter equal to 0.01 means that the scale will at least go from 1-limit = 0.99 to 1+limit = 1.01 times the reference value. The parameter limit.robust is for the situation when there is only one data point that is not NA. The parameter limit.mean uses the mean as reference, and limit.median uses the median value as reference. Note that the lattice plots generally fail (without a prepanel function) if there is only one single point and if that value is very large (for example, y=6e66). The following prepanel functions can be used to handle such situations. The prepanel function can also be used to ascertain that a useful minimum scale of say +/- 0.5% is always shown. Note that the actual scale may be larger (i.e. the selected scale limits will always include the data). See also prepanel.robust.x and prepanel.robust.xy Example (using the xlim version):

N <- 40 # two of which are NA-values

df <- data.frame(model= sample(c("M1"),size=N,replace=TRUE), cap= sample(c("A","B","C"),size=N,replace=TRUE), pA = c(NA,NA,rnorm(N-2,mean=9e99,sd=0.001)))

dotplot(cap ~ pA | paste(model),

limit.mean = 0.05, # Make sure we have an x-scale of at least +/- 5% of the mean

prepanel=prepanel.robust.x,

groups=cap,

auto.key=list(TRUE),

data=df,

panel=function(x,y,...)

panel.dotplot(x,y,...)

)

Usage

none

Arguments

x

gives the x-values.

y

gives the y-values.

...

for additional parameters.

limit.robust

limit to use is there is only one data point.

limit.mean

is the mean-based minimum limit.

limit.median

is the median-based minimum limit.

Value

a list with ylim-values for a trellis plot.

Author(s)

Claus E. Andersen


claus-e-andersen/clanLattice documentation built on Oct. 14, 2023, 10:41 a.m.