# NOT RUN {
lay <- data.frame(A = factor(rep(c(1:3), c(3,6,4)), labels = letters[1:3]))
lay$B <-fac.nested(lay$A)
#Add factors for B within each level of A
lay2 <- cbind(lay, fac.multinested(lay$A))
canon2 <- designAnatomy(list(~A/(a+b+c)), data = lay2)
summary(canon2)
#Add factors for B within each level of A, but with levels and outlabel given
lay2 <- cbind(lay, fac.multinested(lay$A, nested.levs = seq(10,60,10), outlabel = "other"))
# }
# NOT RUN {
canon2 <- designAnatomy(list(~A/(a+b+c)), data = lay2)
summary(canon2)
# }
# NOT RUN {
#Replicate the combinations of A and B three times and index them with the factor sample
lay3 <- rbind(lay,lay,lay)
lay3$sample <- with(lay3, fac.nested(fac.combine(list(A,B))))
#Add factors for B within each level of A
lay4 <- cbind(lay3, fac.multinested(nesting.fac = lay$A, nested.fac = lay$B))
# }
# NOT RUN {
canon4 <- designAnatomy(list(~(A/(a+b+c))/sample), data = lay4)
summary(canon4)
# }
# NOT RUN {
#Add factors for sample within each combination of A and B
lay5 <- with(lay4, cbind(lay4,
fac.multinested(nesting.fac = a, fac.prefix = "a"),
fac.multinested(nesting.fac = b, fac.prefix = "b"),
fac.multinested(nesting.fac = c, fac.prefix = "c")))
# }
# NOT RUN {
canon5 <- designAnatomy(list(~A/(a/(a1+a2+a3)+b/(b1+b2+b3+b4+b5+b6)+c/(c1+c2+c3))), data = lay5)
summary(canon5)
# }
# NOT RUN {
#Add factors for sample within each level of A
lay6 <- cbind(lay4,
fac.multinested(nesting.fac = lay4$A, nested.fac = lay$sample, fac.prefix = "samp"))
canon6 <- designAnatomy(list(~A/(a/sampa+b/sampb+c/sampc)), data = lay6)
summary(canon6)
# }
Run the code above in your browser using DataLab