Methods for class design objects | R Documentation |
Methods for subsetting, aggregating, printing and summarizing class design objects. The formula, lm and plot methods are subject of a separate help page.
## 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, std.order=FALSE, ...)
## 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)
x |
data frame of S3 class |
i |
indices for subsetting rows |
j |
indices for subsetting columns |
drop.attr |
logical, controls whether or not attributes are dropped;
if |
drop |
logical that controls dropping of dimensions in the Extract function for
data.frame objects, which is called by the method for class |
show.order |
|
group.print |
logical, default |
std.order |
logical, default |
... |
further arguments to functions |
object |
data frame of S3 class |
brief |
|
quote |
logical; |
by |
by variables for the |
response |
used for wide format designs only; |
FUN |
a function to be used for aggregation, the default is |
postfix |
|
replace |
logical that decides whether an existing variable of the given name
is to be replaced; the default is |
Items of class design
are data frames with attributes,
that have been created for conducting experiments. Apart from the methods
documented here, separate files document the methods formula.design
and plot.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 method for print
displays the design. Per default, the design is
printed in the actual run order, and run order information is shown for designs
with special structure (blocked, replicated). Optionally, the design can be
printed in standard order, which may be useful for comparing to other designs
or for getting a clearer idea about the structure of smaller designs.
The method for summary
provides design-specific information -
some further development may still be expected. If a standard data frame summary
is desired, explicitly use function summary.data.frame
instead of summary
.
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.
This method calculates a mean, standard deviation or SN ratio from the individual responses
(which can be repeated measurements or outer array runs from a Taguchi parameter design).
extractor |
The extractor function returns a class design object with modified attributes or a data frame without special attributes, depending on the situation. If
|
The print
and summary
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.
The package is currently subject to intensive development; most key functionality is now included. Some changes to input and output structures may still occur.
Ulrike Groemping
See also the following functions known to produce objects of class
design
: FrF2
, pb
, fac.design
, oa.design
.
See also the following further methods for class design
objects:
formula.design
, lm.design
, plot.design
.
Function plot.design
from package graphics works on
data frames with R factors as explanatory variables, if a numeric response is available;
this function is invoked by method plot.design
from this package,
where appropriate.
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 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.