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 factor.names and response.names
factor.names(oa12)
## rename factors
factor.names(oa12) <- c("First.Factor", "Second.Factor", "Third.Factor")
## 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
## 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")
## undesign and redesign
u.oa12 <- undesign(oa12)
u.oa12$new <- rnorm(12)
r.oa12 <- redesign(oa12, u.oa12)
## make known that new is also a respons
response.names(r.oa12) <- c(response.names(r.oa12), "new")
## look at design-specific summary
summary(r.oa12)
## look at data frame style summary instead
summary.data.frame(r.oa12)
Run the code above in your browser using DataLab