From 79917b99f6c27213ecaa3bd8f2ae8d0646edb5c3 Mon Sep 17 00:00:00 2001 From: Walmes Zeviani <walmes@ufpr.br> Date: Tue, 29 Sep 2015 13:56:35 -0300 Subject: [PATCH] Add dataset of a group of experiments, Pimentel pg 147. --- R/legTools.R | 49 +++++++++++++++++++++++++++++++++++ data-raw/cottonFert.R | 59 ++++++++++++++++++++++++++++++++++++++++++ data/cottonFert.RData | Bin 0 -> 554 bytes man/cottonFert.Rd | 48 ++++++++++++++++++++++++++++++++++ 4 files changed, 156 insertions(+) create mode 100644 data-raw/cottonFert.R create mode 100644 data/cottonFert.RData create mode 100644 man/cottonFert.Rd diff --git a/R/legTools.R b/R/legTools.R index 115262b..1845554 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 0000000..b491d9c --- /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 GIT binary patch literal 554 zcmb2|=3oE==C@&nKDQl2Y=7(NZOrIaSQXG6;GwyMTWDd=3H3lmA&$-!%*@@Qb2J|$ ztO+}CsdZ=Z>b#P)cXxKqojLPmSfGQ#p}Rl-Pxv!SZ{3yF$#wVszyDvI{`>jymHXn> z?pUptd?xMAwwY(AYUg}SG(7l;>u!|9@rTc11djH6WSkrJBjDk#m6xnVCw|Z=KmXT% z-RfdL<qBz&ZBwtOZ{pORrY^2-{m1L}`jQV*qwBu;mUe19&*H6@ZoPf{>fb0Cw^O^r zuKi?Pn6_NP-*95m_o|s+e%${x>FA|(n%zt9`ips2Z;RCVp6}Z~{ch6T#aRz+qAYr@ ziCC?_Fw@Vh_|6==zW$QisrSqG)}4qu@W*|x-PUBg)G%q?6Wk}POE>R{pK$yK*C*RE zYwQKiJEk1?oF{9^_D3T@@&oGwj?Vea(-@93cDLwHth!_G^~p7;{ikA+a!P#XlXg!V zkCKV?Ugu<03hf_Eww~}xoHI#o{d(~al3y50e=V%9u)Se^<>>E)&+Xg(UHrY^JoAO! zcjW)=D%zyK)B3WFMbT1?`E|cHd<(KtoAdD;ANTI#pWE+EU3Pl^(hGr!{&o$&<R<G? zh^t4vSYAH!ig#TK*OJLkmM*?JD}GORW$cEAuajmcZ(9;^(IwQ1v+DWD$}hUxU*@y? zm?rG-DdI1GlX<d;$;Icr8`^|-I+uJ3{E^4B^~?M9f8%PmM6Eqv-m`A^yW{^{Y=fdB RjP_kOmpFcG$qG&e1_0_F8}k4F literal 0 HcmV?d00001 diff --git a/man/cottonFert.Rd b/man/cottonFert.Rd new file mode 100644 index 0000000..6a718f3 --- /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} + -- GitLab