genvarattributes {plgraphics}R Documentation

Generate or Set Variable Attributes for Plotting

Description

genvarattributes generates attributes of variables that are useful for the plgraphics functions. It is called by pl.control.
setvarattributes modifies or sets such attributes.

Usage

genvarattributes(data, vnames = NULL, vcol = NULL, vlty = NULL, vpch = NULL,
  varlabels = NULL, innerrange.limits = NULL, replace=FALSE, ploptions = NULL)

setvarattributes(data, attributes = NULL, list = NULL, ...)

Arguments

data

data.frame consisting of the variables (columns) to be characterized by their attributes

vnames

names of variables to be treated as y variables

vcol, vlty, vpch

color, line type and plotting character to be used when multiple y-s are plotted (in the sense of matplot)

varlabels

labels of the variables, in the case that the names of data are not appropriate.

innerrange.limits

limits of the inner plotting range, if predetermined

ploptions

list containing the plotting elements needed to set the attributes

replace

logical: should existing attributes be replaced?

attributes

(for setvarattributes) is a list of lists. Its names identify the variables for which the attributes are set or modified. Each component is a list which is added to the existing attributes of the respective variable or replaces them if they already exist.

list

a list of attributes to be set. Each component must have a name giving the name of the variable attribute to be set, and be itself a list (or a vector). This list must have names that identify the variables in data for which the attributes are set. See examples to understand this.

...

further arguments, which will be collected and used as or added tolist

Details

If the attribute innerrange is replaced, then plcoord is also replaced.

Value

Data.frame, returning the original values, but the variables are supplemented by the following attributes, where available:

nvalues

number of distinct values

innerrange

inner plotting range

plcoord

plotting coordinates

ticksat

tick marks for axis

varlabel

label to be used as axis label

Author(s)

Werner A. Stahel

See Also

par

Examples

data(d.blast)
dd <- genvarattributes(d.blast)
str(attributes(dd$tremor))

ddd <- setvarattributes(dd, list( tremor=list(ticksat=seq(0,24,2),
  ticklabelsat = seq(0,24,10), ticklabels=c("low","medium","high")) ) )
str(attributes(ddd$tremor))

data(d.river)
plyx(O2+H2CO3+T ~ date, data=d.river, subset=as.Date(date)<as.Date("2010-02-28"))
dd <- setvarattributes(d.river,
  list=list(vcol=c(O2="blue", T="red")), vpch=c(O2=1, T="T", H2CO3=5) )
attributes(dd$O2)
plyx(O2+H2CO3+T ~ date, data=d.river, subset=as.Date(date)<as.Date("2010-02-28"))

[Package plgraphics version 1.0 Index]