R: Normal Probability Plot with Multiple Lines and Multiple...
qqnorm2s
R Documentation
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 or a
list of data.frames of the same length as y,
with y[i] being the name of a column of the data.frame data.[[i]].
z is a similar character vector of names of columns of
data., which identify symbols for plotting different points
in a normal probability plot. The lengths of y, and z
must match the number of data.frames in data.; if
not, the lengths of the shorter are replicated to the length of the
longest before computations begin.
For plot.qqnorm2, y is ignored; it is included,
because the generic plot function requires it.
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. of data.frames. If not, the shorter are
replicated to the length of the longer.
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
qqnorm.)
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 FALSE and "o" for TRUE.
If z assumes integer values between 0 and 255, by default,
the symbols are chosen as described with points.
Otherwise, by default, z is coerced to
character, and the result is plotted.
If pch is provided, it must eitehr have names corresponding
to levels of z, or z must be integers between 1 and
length(pch).
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, pch = list(x='right', legend=names(qq2s[[1]][['pch']]),
pch=qq2s[[1]][['pch']]), where qq2s is described below in
details.
Similarly, by default, lines = list(x='bottomright', legend=y,
lty=1, pch=NA, col=qq2s[[1]][['col']]).
...
Optional arguments.
For plot.qqnorm2s, they are passed to plot.
For qqnorm2s, they are passed to qqnorm2 and to
plot.qqnorm2s.
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.
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.".
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(Ecfun)
Attaching package: 'Ecfun'
The following object is masked from 'package:base':
sign
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Ecfun/qqnorm2s.Rd_%03d_medium.png", width=480, height=480)
> ### Name: qqnorm2s
> ### Title: Normal Probability Plot with Multiple Lines and Multiple Symbols
> ### Aliases: qqnorm2s plot.qqnorm2s
> ### Keywords: plot
>
> ### ** Examples
>
> ##
> ## 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'
>
> ## Don't show:
> stopifnot(
+ ## End(Don't show)
+ all.equal(Qn2, Qn2.)
+ ## Don't show:
+ )
> ## End(Don't show)
> ##
> ## 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' )
>
>
>
>
>
>
> dev.off()
null device
1
>