diff --git a/R/legTools.R b/R/legTools.R index 502dfd7466343b619801d42d60c8a43d0ad605eb..e063ffe004fcc55f393db350b56edd7a0f2e775d 100644 --- a/R/legTools.R +++ b/R/legTools.R @@ -1439,3 +1439,69 @@ NULL #' } #' NULL + +#' @name cornYield3 +#' +#' @title An triple lattice design in corn yield +#' +#' @description This is a experiment evaluating the yield (kg/plot) for +#' 16 corn hybrids in a triple lattice design. +#' +#' \itemize{ +#' +#' \item \code{rept} a categorical unordered factor with 3 levels. +#' +#' \item \code{block} a categorical unordered factor with 4 levels in +#' each \code{rept}, so 12 at all. Each block has size 4. +#' +#' \item \code{hybrid} a unordered factor with 16 levels, the corn +#' hybrids studied. +#' +#' \item \code{yield} the (continuous) response variable of the +#' experiment in kg/plot. +#' +#' } +#' +#' @docType data +#' +#' @keywords datasets +#' +#' @usage data(cornYield3) +#' +#' @format a \code{data.frame} with 48 records and 4 variables. +#' +#' @source Pimentel Gomes, F. (2009). Curso de EstatÃstica Experimental +#' (15th ed.). Piracicaba, São Paulo: FEALQ. (page 215) +#' +#' @examples +#' +#' require(lattice) +#' +#' data(cornYield3) +#' str(cornYield3) +#' +#' xyplot(yield~hybrid|rept, groups=block, +#' data=cornYield3, type="b", +#' ylab=expression(Yield~(kg~plot^{-1})), +#' xlab="Hybrid") +#' +#' xyplot(yield~hybrid, data=cornYield3, +#' jitter.x=TRUE, type=c("p", "a"), +#' ylab=expression(Yield~(kg~plot^{-1})), +#' xlab="Hybrid") +#' +#' g <- nlevels(cornYield3$hybrid) +#' a <- seq(0, by=(2*pi)/(g), length.out=g) +#' y <- sin(a) +#' x <- cos(a) +#' plot(y~x, asp=1, xlim=c(-1,1), ylim=c(-1,1)) +#' +#' for (b in levels(cornYield3$block)){ +#' cbn <- combn(x=as.integer(cornYield3$hybrid[cornYield3$block==b]), +#' m=2) +#' segments( +#' x0=x[cbn[1,]], y0=y[cbn[1,]], +#' x1=x[cbn[2,]], y1=y[cbn[2,]], col=b) +#' } +#' +NULL diff --git a/data-raw/cornYield3.R b/data-raw/cornYield3.R new file mode 100644 index 0000000000000000000000000000000000000000..6053d7cecbaff1d7867a4dfe3cc9b1ad84c4bb56 --- /dev/null +++ b/data-raw/cornYield3.R @@ -0,0 +1,98 @@ +##---------------------------------------------------------------------- +## Data generation. Pimentel page 215. + +cornYield3 <- read.table("clipboard", header=FALSE, sep="\t") +cornYield3[, 4] <- as.numeric(sub(x=cornYield3[, 4], ",", ".")) +names(cornYield3) <- c("rept", "block", "hybrid", "yield") +cornYield3 <- transform(cornYield3, rept=factor(rept), + block=factor(block), hybrid=factor(hybrid)) +cornYield3 <- cornYield3[ + with(cornYield3, order(rept, block, hybrid)), ] +dput(cornYield3) + +cornYield3 <- structure(list( + rept = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, + 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, + 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, + 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), + .Label = c("1", "2", "3"), + class = "factor"), + block = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, + 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, + 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, + 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L), + .Label = c("1", "2", "3", "4"), + class = "factor"), + hybrid = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, + 12L, 13L, 14L, 15L, 16L, 1L, 5L, 9L, 13L, 2L, + 6L, 10L, 14L, 3L, 7L, 11L, 15L, 4L, 8L, 12L, + 16L, 1L, 6L, 11L, 16L, 2L, 5L, 12L, 15L, 3L, + 8L, 9L, 14L, 4L, 7L, 10L, 13L), + .Label = c("1", "2", "3", "4", "5", "6", "7", + "8", "9", "10", "11", "12", "13", + "14", "15", "16"), + class = "factor"), + yield = c(2, 2.9, 2.2, 3.9, 2.3, 2.5, 1.4, 1.7, 1.6, 3, 1.5, 2.1, + 2.3, 3.4, 2, 2.8, 2.2, 2.3, 2.7, 1.4, 3.1, 2.8, 2.6, 2.8, + 3.1, 2.9, 2.5, 2.4, 4, 2.8, 2.7, 1.5, 3, 2.9, 2.6, 3.1, + 1.8, 1.9, 2.9, 2.5, 1.7, 2, 1.4, 2.3, 4.4, 3.7, 3.3, + 2.2)), + row.names=1:48, + class = "data.frame") + +str(cornYield3) + +save(cornYield3, file="../data/cornYield3.RData") + +##---------------------------------------------------------------------- + +aggregate(yield~block+rept, data=cornYield3, FUN=sum) +aggregate(yield~hybrid, data=cornYield3, FUN=sum) + +m0 <- aov(terms(yield~rept/block+hybrid, keep.order=TRUE), + data=cornYield3) +anova(m0) + +library(doBy) +L <- LSmeans(m0, effect="hybrid") + +str(L) +L$K + +##---------------------------------------------------------------------- +## Examples. + +require(lattice) + +data(cornYield3) +str(cornYield3) + +xyplot(yield~hybrid|rept, groups=block, + data=cornYield3, type="b", + ylab=expression(Yield~(kg~plot^{-1})), + xlab="Hybrid") + +xyplot(yield~hybrid, data=cornYield3, + jitter.x=TRUE, type=c("p", "a"), + ylab=expression(Yield~(kg~plot^{-1})), + xlab="Hybrid") + +g <- nlevels(cornYield3$hybrid) +a <- seq(0, by=(2*pi)/(g), length.out=g) +y <- sin(a) +x <- cos(a) +plot(y~x, asp=1, xlim=c(-1,1), ylim=c(-1,1)) + +for (b in levels(cornYield3$block)){ + cbn <- combn(x=as.integer(cornYield3$hybrid[cornYield3$block==b]), + m=2) + segments( + x0=x[cbn[1,]], y0=y[cbn[1,]], + x1=x[cbn[2,]], y1=y[cbn[2,]], col=b) +} + + +rm(list=ls()) +load("../data/cornYield3.RData") +ls() +str(cornYield3) diff --git a/data/cornYield3.RData b/data/cornYield3.RData new file mode 100644 index 0000000000000000000000000000000000000000..521496e22cc5b63519d06ff5eb2fef5a14d7fc66 Binary files /dev/null and b/data/cornYield3.RData differ diff --git a/man/cornYield3.Rd b/man/cornYield3.Rd new file mode 100644 index 0000000000000000000000000000000000000000..bc07fdf3594dd3a6925748225259a9ef6621f8da --- /dev/null +++ b/man/cornYield3.Rd @@ -0,0 +1,65 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/legTools.R +\docType{data} +\name{cornYield3} +\alias{cornYield3} +\title{An triple lattice design in corn yield} +\format{a \code{data.frame} with 48 records and 4 variables.} +\source{ +Pimentel Gomes, F. (2009). Curso de EstatÃstica Experimental + (15th ed.). Piracicaba, São Paulo: FEALQ. (page 215) +} +\usage{ +data(cornYield3) +} +\description{ +This is a experiment evaluating the yield (kg/plot) for + 16 corn hybrids in a triple lattice design. + +\itemize{ + +\item \code{rept} a categorical unordered factor with 3 levels. + +\item \code{block} a categorical unordered factor with 4 levels in + each \code{rept}, so 12 at all. Each block has size 4. + +\item \code{hybrid} a unordered factor with 16 levels, the corn + hybrids studied. + +\item \code{yield} the (continuous) response variable of the + experiment in kg/plot. + +} +} +\examples{ +require(lattice) + +data(cornYield3) +str(cornYield3) + +xyplot(yield~hybrid|rept, groups=block, + data=cornYield3, type="b", + ylab=expression(Yield~(kg~plot^{-1})), + xlab="Hybrid") + +xyplot(yield~hybrid, data=cornYield3, + jitter.x=TRUE, type=c("p", "a"), + ylab=expression(Yield~(kg~plot^{-1})), + xlab="Hybrid") + +g <- nlevels(cornYield3$hybrid) +a <- seq(0, by=(2*pi)/(g), length.out=g) +y <- sin(a) +x <- cos(a) +plot(y~x, asp=1, xlim=c(-1,1), ylim=c(-1,1)) + +for (b in levels(cornYield3$block)){ + cbn <- combn(x=as.integer(cornYield3$hybrid[cornYield3$block==b]), + m=2) + segments( + x0=x[cbn[1,]], y0=y[cbn[1,]], + x1=x[cbn[2,]], y1=y[cbn[2,]], col=b) +} +} +\keyword{datasets} +