## S3 method for class 'design':
[(x, i, j, drop.attr = TRUE, drop = FALSE)
## S3 method for class 'design':
print(x, show.order=NULL, group.print=TRUE, ...)
showData(dataframe,colname.bgcolor = "grey50",
rowname.bgcolor = "grey50",
body.bgcolor = "white",
colname.textcolor = "white",
rowname.textcolor = "white",
body.textcolor = "black",
font = "Courier 12",
maxheight = 30,
maxwidth = 80,
title = NULL,
rowname.bar = "left",
colname.bar = "top",
rownumbers = FALSE,
placement = "-20-40",
suppress.X11.warnings = TRUE)
## S3 method for class 'default':
showData(dataframe,
colname.bgcolor = "grey50",
rowname.bgcolor = "grey50",
body.bgcolor = "white",
colname.textcolor = "white",
rowname.textcolor = "white",
body.textcolor = "black",
font = "Courier 12",
maxheight = 30,
maxwidth = 80,
title = NULL,
rowname.bar = "left",
colname.bar = "top",
rownumbers = FALSE,
placement = "-20-40",
suppress.X11.warnings = TRUE)
## S3 method for class 'design':
showData(dataframe,
colname.bgcolor = "grey50",
rowname.bgcolor = "grey50",
body.bgcolor = "white",
colname.textcolor = "white",
rowname.textcolor = "white",
body.textcolor = "black",
font = "Courier 12",
maxheight = 30,
maxwidth = 80,
title = NULL,
rowname.bar = "left",
colname.bar = "top",
rownumbers = FALSE,
placement = "-20-40",
suppress.X11.warnings = TRUE)
## S3 method for class 'design':
summary(object, brief = NULL, quote = FALSE, ...)
## S3 method for class 'design':
aggregate(x, ...,
by = NULL, response = NULL, FUN = "mean", postfix = NULL, replace = TRUE)
## S3 method for class 'design':
plot(x, y=NULL, select=NULL, ...)
design
TRUE
, the result is no longer of class design
, and all special design attributes are dropped;
otherwise, the design attributes are adjusted to reflect tdesign
NULL
or logical; if TRUE
, the design is printed with run order information;
default is TRUE
for design types for which this information is helpful (see code for detail), FALSE
otherwiseTRUE
;
if TRUE
, structured designs (blocked and split-plot designs)
are printed with intermediate lines at structure breaks;
if FALSE
, the designs are simply printed as ddesign
, the method for design
is used,
otherwise the default methoddesign
, like argument design
NULL
or logical; TRUE
requests a printout of the
design at the end of the summary
output, FALSE
suppresses such a printout.
If brief = NULL
(the default), the summary
TRUE
requests quoting strings in print parts of the output,
FALSE
suppresses quotes.data frame method
of function aggregate
,
needed if x
is not a wide design for which the special
method forNULL
, all responses of the design are aggregated;
specify names of selected responses (column names of the responselist
element
of the design.info
attribute) f"mean"
;
can be used like the FUN
argument to apply
NULL
implies postfixing the response name with (a character version of)
FUN
; a character string can be given instead for a user-defined postfixTRUE
for convenience reasons.
WARNING: If custom variables other than aggregation variables are added to wide format desigx
to be plotted as responses,
or a numeric response vector, or a numeric matrix containing response columns,
or a data frame of numeric response variables (the latter would nselect
has been added in order to obtainj
is given, the function always returns a data frame without
special attributes, even if drop.attr=FALSE
or j=1:ncol(design)
.
If only i
is given,
the default option drop.attr=TRUE
also returns a
data frame without attributes.
Exception: Even for drop.attr=TRUE
, if i
is a permutation of
the row numbers or a logical vector with all elements TRUE
,
the attributes are preserved, and attributes run.order
and desnum
are reordered along with the design, if necessary.
If drop.attr=FALSE
and j
is empty,
the function returns an object of class design with rows of attributes run.order
and desnum
selected in line with those of the design itself.
In this case, the new design.info
attribute is a list with entries
[object Object],[object Object],[object Object]print
, summary
and plot
methods are called for their side effects and return NULL
.
The method for aggregate
returns the input wide format design with one or more
additional response columns and the response.names
element of the
design.info
attribute changed to only include the newly-added responses.design
are data frames with attributes,
that have been created for conducting experiments. Apart from the methods
documented here, a separate file documents the method formula.design
.
The extractor method subsets the design, taking care of the attributes accordingly (cf. the value section).
Subsetting can also handle replication in a limited way, although this is not first
choice. Repeated measurements can be added to a design that has no proper replications,
and proper replications can be added to a design that has no repeated measurements.
The methods for print
or summary
provide design-specific information -
especially the summary
method will develop further. If a standard data frame summary
is desired, explicitly use function summary.data.frame
instead of summary
.
The default method for showData
is the function from package design
objects
is needed for successfully using the view button of design
dataframes in R-commander.
They are undesigned before viewing. However, it is preferrable to inspect a printout from function
print.design
which provides additional information.
This can also be done in the R-Commander using the Design
menu in package RcmdrPlugin.DoE
(to be available soon).
The method for aggregate
provides aggregation utilities for wide format designs and
links back to the method for data frames for designs that are not of wide format.
If a wide format design is to be treated with the aggregate
method for data frames,
aggregate.data.frame
must be used explicitly.
The method for plot
calls the method available in package graphics
(see plot.design
) wherever this makes sense (x
not of class design
,
x
of class design
but not following the class design
structure
defined in package x
a design with all factors being R-factors and at least one response available).
Function plot.design
from package link{oa.design}
), function plot.design
creates a mosaic plot of
the frequency table of the design, which may be quite useful to understand the structure
for designs with relatively few factors (cf. example below; function plot.design
calls
function mosaic
for this purpose).
For designs with at least one experimental factor that is not an R-factor, function
plot.design
calls function plot.data.frame
in order
to create a scatter plot matrix.
Currently, there is no good method for plotting designs with mixed qualitative
and quantitative factors.design
: FrF2
, pb
, fac.design
, oa.design
,
and function plot.design
from package graphics;
a method for function lm
is described in the separate help file
lm.design
.oa12 <- oa.design(nlevels=c(2,2,6))
#### Examples for extractor function
## subsetting to half the runs drops all attributes per default
oa12[1:6,]
## keep the attributes (usually not reasonable, but ...)
oa12[1:6, drop.attr=FALSE]
## reshuffling a design
## (re-)randomize
oa12[sample(12),]
## add repeated measurements
oa12[rep(1:12,each=3),]
## add a proper replication
## (does not work for blocked designs)
oa12[c(sample(12),sample(12)),]
## subsetting and rbinding to loose also contrasts of factors
str(rbind(oa12[1:2,],oa12[3:12]))
## keeping all non-design-related attributes like the contrasts
str(undesign(oa12))
#### Examples for plotting designs
## plotting a design without response (uses function mosaic from package vcd)
plot(oa12)
## equivalent to mosaic(~A+B+C, oa12)
## alternative order:
mosaic(~C+A+B, oa12)
## using the select function: the plots show that the projection for factors
## C, D and E (columns 3, 14 and 15 of the array) is a full factorial,
## while A, D and E does (columns 1, 14, and 15 of the array) do not occur in
## all combinations
plot(oa.design(L24.2.13.3.1.4.1,nlevels=c(2,2,2,3,4)),select=c("E","D","A"))
plot(oa.design(L24.2.13.3.1.4.1,nlevels=c(2,2,2,3,4)),select=c("E","D","C"))
## plotting a design with response
y=rnorm(12)
plot(oa12, y)
## plot design with a response included
oa12.r <- add.response(oa12,y)
plot(oa12.r)
## plotting a numeric design (with or without response,
## does not make statistical sense here, for demo only)
noa12 <- qua.design(oa12, quantitative="all")
plot(noa12, y, main="Scatter Plot Matrix")
#### Examples print and summary
## rename factors and relabel levels of first two factors
namen <- c(rep(list(c("current","new")),2),list(""))
names(namen) <- c("First.Factor", "Second.Factor", "Third.Factor")
factor.names(oa12) <- namen
oa12 ### printed with the print method!
## add a few variables to oa12
responses <- cbind(temp=sample(23:34),y1=rexp(12),y2=runif(12))
oa12 <- add.response(oa12, responses)
response.names(oa12)
## temp (for temperature) is not meant to be a response
## --> drop it from responselist but not from data
response.names(oa12) <- c("y1","y2")
## print design
oa12
## look at design-specific summary
summary(oa12)
## look at data frame style summary instead
summary.data.frame(oa12)
## aggregation examples
plan <- oa.design(nlevels=c(2,6,2), replications=2, repeat.only=TRUE)
y <- rnorm(24)
z <- rexp(24)
plan <- add.response(plan, cbind(y=y,z=z))
plan <- reptowide(plan)
plan.mean <- aggregate(plan)
plan.mean
aggregate(plan, response="z")
aggregate(plan, FUN=sd)
aggregate(plan, FUN = function(obj) max(obj) - min(obj), postfix="range")
## several aggregates: add standard deviations to plan with means
plan.mean.sd <- aggregate(plan.mean, FUN=sd)
plan.mean.sd
response.names(plan.mean.sd)
## change response.names element of design.info back to y.mean and z.mean
## may be needed for automatic analysis routines that have not been
## created yet
plan.mean.sd <- aggregate(plan.mean.sd, FUN=mean)
plan.mean.sd
response.names(plan.mean.sd)
Run the code above in your browser using DataLab