diff --git a/R/legTools.R b/R/legTools.R index 115262bcc6e803a275f684b71032537541b8e399..18455541cb46eb047585f3c5dbb83888f2720da1 100644 --- a/R/legTools.R +++ b/R/legTools.R @@ -816,3 +816,52 @@ NULL #' xlab="Nutrient level") #' NULL + +#' @name cottonFert +#' +#' @title A set of experiments in different locations studing NK on cotton +#' +#' @description These data is a set of experiments carried out in +#' different locations studing NK fertilization in cotton. All the 5 +#' experiments are a complete randomized design with 4 replications +#' and 5 levels of fertilization based on N and K levels and a +#' control. +#' +#' \itemize{ +#' \item \code{trt} unordered factor, treatment that consist of 4 +#' cells from a 2^2 factorial design (\eqn{N\times K}) and a +#' control. +#' \item \code{rept} integer, indexes experimental units. +#' \item \code{loc} an unordered factor representing the locations +#' where the experiment was carried out. +#' \item \code{y} numeric, the response variable of the +#' experiment. The text book didn't give details. +#' } +#' +#' @docType data +#' +#' @keywords datasets +#' +#' @usage data(cottonFert) +#' +#' @format a \code{data.frame} with 100 records and 4 variables. +#' +#' @source Pimentel Gomes, F. (2009). Curso de Estatística Experimental +#' (15th ed.). Piracicaba, São Paulo: FEALQ. (page 142) +#' +#' @examples +#' +#' library(lattice) +#' +#' data(cottonFert) +#' str(cottonFert) +#' +#' xyplot(y~trt|loc, +#' data=cottonFert, type=c("p", "a"), +#' ylab="y", xlab="Treatment") +#' +#' xyplot(log(y)~trt|loc, +#' data=cottonFert, type=c("p", "a"), +#' ylab="y", xlab="Treatment") +#' +NULL diff --git a/data-raw/cottonFert.R b/data-raw/cottonFert.R new file mode 100644 index 0000000000000000000000000000000000000000..b491d9c7fea40909f263ffc96bf4d5c664cc162f --- /dev/null +++ b/data-raw/cottonFert.R @@ -0,0 +1,59 @@ +##---------------------------------------------------------------------- +## Data generation. + +cottonFert <- expand.grid( + ## K=c(-1, 1), + ## N=c(-1, 1), + trt=c("N1K1", "N1K2", "N2K1", "N2K2", "CTRL"), + rept=1:4, + loc=gl(5, 1), + KEEP.OUT.ATTRS=FALSE) + +## x <- scan() +## dput(x/10) + +cottonFert$y <- c(4.2, 3.6, 3.2, 3.6, 2.4, 2.4, 2.2, 2.6, 2.8, 1.2, 2.8, + 1.8, 3, 3, 3, 3.2, 3.2, 2, 2.4, 2.8, 11, 10, 12, 10.5, + 8.5, 10.5, 9.5, 9, 11.5, 8, 9, 9, 9.5, 10.5, 10, 9, 8, + 9.5, 10, 7, 7, 8.5, 9, 9, 7, 7.5, 7, 6, 9.5, 7, 6.5, + 8, 6, 8, 4.5, 5.5, 5.5, 5.5, 7, 6, 8, 8, 7, 9, 3.5, + 6.9, 5.5, 4.7, 6.5, 3, 6, 7.5, 5.5, 5.5, 3.9, 6.5, 8, + 9, 7, 7, 1.72, 2.38, 2.52, 2.78, 1.48, 1.81, 2.56, + 2.88, 3.01, 1.62, 1.73, 2.48, 2.76, 2.83, 1.58, 1.62, + 2.43, 2.54, 2.79, 1.56) + +## Check using the totals. +aggregate(y~loc, data=cottonFert, FUN=sum) + +str(cottonFert) + +save(cottonFert, file="../data/cottonFert.RData") + +##---------------------------------------------------------------------- +## Examples. + +library(lattice) + +data(cottonFert) +str(cottonFert) + +xyplot(y~trt|loc, + data=cottonFert, type=c("p", "a"), + ylab="y", xlab="Treatment") + +xyplot(log(y)~trt|loc, + data=cottonFert, type=c("p", "a"), + ylab="y", xlab="Treatment") + +m0 <- by(data=cottonFert, INDICES=cottonFert$loc, + FUN=lm, formula=y~trt) +lapply(m0, anova) + +m1 <- lm(y~loc*trt, data=cottonFert) + +par(mfrow=c(2,2)); plot(m1); layout(1) +MASS::boxcox(m1) + +m2 <- lm(log(y)~loc*trt, data=cottonFert) +par(mfrow=c(2,2)); plot(m2); layout(1) +anova(m2) diff --git a/data/cottonFert.RData b/data/cottonFert.RData new file mode 100644 index 0000000000000000000000000000000000000000..bcaa7cc3daa034575c269eb08eeba25b8f71b353 Binary files /dev/null and b/data/cottonFert.RData differ diff --git a/man/cottonFert.Rd b/man/cottonFert.Rd new file mode 100644 index 0000000000000000000000000000000000000000..6a718f3aa3256acf21e2da066c9e5f95997fc943 --- /dev/null +++ b/man/cottonFert.Rd @@ -0,0 +1,48 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/legTools.R +\docType{data} +\name{cottonFert} +\alias{cottonFert} +\title{A set of experiments in different locations studing NK on cotton} +\format{a \code{data.frame} with 100 records and 4 variables.} +\source{ +Pimentel Gomes, F. (2009). Curso de Estatística Experimental + (15th ed.). Piracicaba, São Paulo: FEALQ. (page 142) +} +\usage{ +data(cottonFert) +} +\description{ +These data is a set of experiments carried out in + different locations studing NK fertilization in cotton. All the 5 + experiments are a complete randomized design with 4 replications + and 5 levels of fertilization based on N and K levels and a + control. + +\itemize{ + \item \code{trt} unordered factor, treatment that consist of 4 + cells from a 2^2 factorial design (\eqn{N\times K}) and a + control. + \item \code{rept} integer, indexes experimental units. + \item \code{loc} an unordered factor representing the locations + where the experiment was carried out. + \item \code{y} numeric, the response variable of the + experiment. The text book didn't give details. +} +} +\examples{ +library(lattice) + +data(cottonFert) +str(cottonFert) + +xyplot(y~trt|loc, + data=cottonFert, type=c("p", "a"), + ylab="y", xlab="Treatment") + +xyplot(log(y)~trt|loc, + data=cottonFert, type=c("p", "a"), + ylab="y", xlab="Treatment") +} +\keyword{datasets} +