djoin: Join designs together into a blocked design

View source: R/ccd.R

djoinR Documentation

Join designs together into a blocked design

Description

This implements the rsm package's building-block provisions for handling sequences of experiments. We often want to join two or more designs into one blocked design for purposes of analysis.

Usage

djoin(design1, design2, ..., blkname = "Block", blocklev)
stdorder(design)

Arguments

design1

A coded.data object (must have been created by rsm 2.00 or higher).

design2

A data.frame (or coded.data) to be appended; or a call to a function that will create a design

...

Additional designs to be appended

blkname

Name to give to the blocking variable that distinguishes the designs that are joined

blocklev

Label to use in the blocking variable for the added design

design

A coded.data object to be displayed.

Details

djoin may be used to augment a design with all manner of other designs, including regular designs generated by cube and its relatives, data.frames, and other coded.data objects. The underlying paradigm is that each design joined is a separate block, and the order in which they are joined could matter.

It tries to do this in a smart way: The first design, design1, is required to be a coded.data object. If design2 is a data.frame, and variables with the coded names are not present, it is automatically coded according to design1's coding formulas. If design2 is a coded.data object, and its coding formulas differ from those of design1, then design1 is recoded with design2's codings before the designs are joined. In both cases, any variables in design2 not matched in design1 are excluded, and any design1 variables absent in design2 are added with values of NA.

Value

djoin returns a coded.data object with the combined designs, and coding formulas from the last coded.data object added. The generated blocking variable will be a factor. The designs are sorted by blocks and run.order within blocks; and its row.names will be integers corresponding to this ordering.

The function stdorder sorts such data by block and std.order within block to display the designs in their pre-randomized order.

Author(s)

Russell V. Lenth

See Also

cube, coded.data, bbd

Examples

# Some existing data
CR1 <- coded.data(ChemReact1, x1 ~ (Time - 85)/5, x2 ~ (Temp - 175)/5)
# add the second part of the experiment; it gets coded automagically
djoin(CR1, ChemReact2)

# A new experiment in a different part of the design space
newdes <- cube(Yield ~ x1 + x2,  n0 = 3, 
    coding = c(x1 ~ (Time - 70)/10, x2 ~ (Temp - 180)/5))
# Time passes ... we do the experiment and plug-in the observed Yield values
newdes$Yield <- rnorm(7, 75, 3) # these are our pretend results
combined <- djoin(CR1, newdes)
# Observe that the combined dataset is recoded to the new formulas
print(combined, decode = FALSE)

# List the new design in standard order
stdorder(newdes)

rsm documentation built on June 22, 2024, 9:42 a.m.