Learn R Programming

Ecfun (version 0.1-4)

qqnorm2s: Normal Probability Plot with Multiple Lines and Multiple Symbols

Description

Create a normal probability plot with multiple lines for different variables and different symbols for the values of another variable. qqnorm2s produces an object of class qqnorm2s, whose plot method produces the plot.

Usage

qqnorm2s(y, z, data., plot.it=TRUE, datax=TRUE, outnames=y,
         pch=NULL, col=c(1:4, 6), legend.=NULL, ...)
## S3 method for class 'qqnorm2s':
plot(x, y, ...)

Arguments

y
For qnorm2s, y is a character vector of names of columns of data. for which normal probability plots are desired. data. is either a data.frame
z
A character vector giving the names of columns of data. to indicate different plotting symbols. z should be the same length as y and must equal the number of data.frames in the list data.
data.
a data.frame or a list of data.frames with columns named in y and z.
plot.it
logical: Should the result be plotted?
datax
The datax argument of qqnorm: If TRUE, the data are displayed on the horizontal rather than the vertical axis. (The default value for datax is the opposite of that for
outnames
Names for the components of the qqnorm2s object returned by the qqnorm2s function.
pch
a named vector of the plotting symbols to be used with names corresponding to the levels of z. By default, if z takes levels FALSE and TRUE (or 0 and 1), pch=c(4, 1) to plot a "x" for FALS
col
A vector indicating the colors corresponding to each element of y. Defaults to rep(c(1:4, 6), length=length(y)), with 1:4 and 6 being black, red, green, blue, and pink.
x
an object of class qqnorm2.
legend.
A list with components pch and col providing information for legend to identify the plotting symbols (pch) and colors (col). By default, p
...
Optional arguments. For plot.qqnorm2s, they are passed to plot. For qqnorm2s, they are passed to qqnorm2 and to plot.qqnorm2s.

Value

  • qqnorm2s returns a named list with components of class qqnorm2 with names = y with each component having an additional component col plus one called "legend.".

Details

For qqnorm2s: 1. Create qq2s = a list of objects of class qqnorm2 2. Add legend. to qq2s. 3. class(qq2s) <- 'qqnorm2s' 4. if(plot.it)plot(qq2s, ...) 5. Silently return(qq2s). For plot.qqnorm2s, create a plot with one line for each variable named in y.

See Also

qqnorm2 plot

Examples

Run this code
##
## One data.frame
##
tstDF2 <- data.frame(y=1:3, y2=3:5, z2=c(TRUE, TRUE, FALSE),
                    z3=c('tell', 'me', 'why'), z4=c(1, 2.4, 3.69) )
# produce the object and plot it
Qn2 <- qqnorm2s(c('y', 'y2'), 'z2', tstDF2)

# plot the object previously created
plot(Qn2)

# Check the object
qy <- with(tstDF2, qqnorm2(y, z2, type='b'))
qy$col <- 1
qy2 <- with(tstDF2, qqnorm2(y2, z2, type='b'))
qy2$col <- 2
legend. <- list(pch=list(x='right', legend=c('FALSE', 'TRUE'),
                pch=c('FALSE'=4, 'TRUE'= 1)),
                col=list(x='bottomright', legend=c('y', 'y2'),
                lty=1, col=1:2))
Qn2. <- list(y=qy, y2=qy2, legend.=legend.)
class(Qn2.) <- 'qqnorm2s'

stopifnot(
all.equal(Qn2, Qn2.)
)
##
## Two data.frames
##
tstDF2b <- tstDF2
tstDF2b$y <- c(0.1, 0.1, 9)
Qn2b <- qqnorm2s('y', 'z2', list(tstDF2, tstDF2b),
           outnames=c('ok', 'oops'), log='x' )

Run the code above in your browser using DataLab