From 86444c9518fac1810d8216f18673ce6263c3a81f Mon Sep 17 00:00:00 2001
From: Walmes Zeviani <walmes@ufpr.br>
Date: Mon, 28 Sep 2015 18:38:59 -0300
Subject: [PATCH] Add dataset from a 2^3 RBD experimento with coffee.

---
 R/legTools.R           |  52 +++++++++++++++++++++++++++
 data-raw/coffeeFert.R  |  78 +++++++++++++++++++++++++++++++++++++++++
 data/coffeeFert.RData  | Bin 0 -> 385 bytes
 man/cassavaYield.Rd    |   4 +--
 man/coffeeFert.Rd      |  52 +++++++++++++++++++++++++++
 man/cornYield.Rd       |   4 +--
 man/cornYield2.Rd      |   8 ++---
 man/filterCake.Rd      |   4 +--
 man/mangoAcidity.Rd    |   7 ++--
 man/plowing.Rd         |   4 +--
 man/potatoYield.Rd     |   4 +--
 man/sugarcaneYield.Rd  |   4 +--
 man/sugarcaneYield2.Rd |   4 +--
 man/sugarcaneYield3.Rd |   4 +--
 man/sugarcaneYield4.Rd |   4 +--
 man/vinasseFert.Rd     |   4 +--
 man/wgPigs.Rd          |   4 +--
 man/wgPigs2.Rd         |   4 +--
 18 files changed, 213 insertions(+), 32 deletions(-)
 create mode 100644 data-raw/coffeeFert.R
 create mode 100644 data/coffeeFert.RData
 create mode 100644 man/coffeeFert.Rd

diff --git a/R/legTools.R b/R/legTools.R
index 16239ec..115262b 100644
--- a/R/legTools.R
+++ b/R/legTools.R
@@ -764,3 +764,55 @@ NULL
 #'        xlab="Nutrient content")
 #'
 NULL
+
+#' @name coffeeFert
+#'
+#' @title Number of dry branches in coffee trees as function of NPK
+#'
+#' @description These data are from a \eqn{2^3} factorial experiment
+#'     studing the effect of NPK fertilizaton on the number of dry
+#'     branches in coffee trees.
+#'
+#' \itemize{
+#'   \item \code{N} content of nitrogen in the fertilizer (low/high).
+#'   \item \code{P} content of phosphorus in the fertilizer (low/high).
+#'   \item \code{K} content of potassium in the fertilizer (low/high).
+#'   \item \code{block} an unordered factor representing the blocks
+#'     used.
+#'   \item \code{branches} an integer variable, the number of dry
+#'     branches in a coffee the.
+#' }
+#'
+#' @details The experiment was carried out in a randomized block design
+#'     with 6 blocks. In the book, the data is presented at squared root
+#'     scale.
+#'
+#' @docType data
+#'
+#' @keywords datasets
+#'
+#' @usage data(coffeeFert)
+#'
+#' @format a \code{data.frame} with 48 records and 5 variables.
+#'
+#' @source Pimentel Gomes, F. (2009). Curso de Estatística Experimental
+#'     (15th ed.). Piracicaba, São Paulo: FEALQ. (page 137)
+#'
+#' Malavolta, E.; Pimentel Gomes, F.; Coury, T. (1958). Estudos sobre a
+#'     alimentação mineral do cafeeiro (\emph{Coffea arabica} L.,
+#'     variedade Bourbon Vermelho). Piracicaba.
+#'
+#' @examples
+#'
+#' library(lattice)
+#' library(latticeExtra)
+#'
+#' data(coffeeFert)
+#' str(coffeeFert)
+#'
+#' xyplot(branches~N|P, groups=K,
+#'        data=coffeeFert, type=c("p", "a"),
+#'        ylab=expression(Branches~(plant^{-1})),
+#'        xlab="Nutrient level")
+#'
+NULL
diff --git a/data-raw/coffeeFert.R b/data-raw/coffeeFert.R
new file mode 100644
index 0000000..f799d12
--- /dev/null
+++ b/data-raw/coffeeFert.R
@@ -0,0 +1,78 @@
+##----------------------------------------------------------------------
+## Data generation.
+
+coffeeFert <- expand.grid(N=c(-1,1), P=c(-1,1), K=c(-1,1),
+                          block=gl(6, 1), KEEP.OUT.ATTRS=FALSE)
+
+coffeeFert$branches <- c(104, 29, 73, 78, 71, 5, 44, 19, 57, 58, 155,
+                         45, 13, 10, 39, 4, 58, 22, 53, 14, 25, 1, 15,
+                         3, 111, 11, 70, 9, 21, 1, 11, 7, 64, 30, 64,
+                         89, 64, 15, 84, 7, 21, 18, 37, 15, 23, 5, 10,
+                         0)
+
+## coffeeFert$sqrtBranches <- sqrt(coffeeFert$branches)
+
+str(coffeeFert)
+
+save(coffeeFert, file="../data/coffeeFert.RData")
+
+##----------------------------------------------------------------------
+## Examples.
+
+library(lattice)
+library(latticeExtra)
+
+data(coffeeFert)
+str(coffeeFert)
+
+xyplot(branches~N|P, groups=K,
+       data=coffeeFert, type=c("p", "a"),
+       ylab=expression(Branches~(plant^{-1})),
+       xlab="Nutrient level")
+
+range(coffeeFert$branches)
+
+## Sum a positive number to avoid zeros and allow BoxCox
+## transformation.
+m0 <- lm(branches+1~block+(N+P+K)^3, data=coffeeFert)
+
+## Departures from homecedasticity and normality.
+par(mfrow=c(2,2)); plot(m0); layout(1)
+
+MASS::boxcox(m0)
+abline(v=0, col=2)
+
+m1 <- update(m0, log(.)~.)
+par(mfrow=c(2,2)); plot(m1); layout(1)
+
+anova(m1)
+
+m2 <- update(m1, .~block+N*K)
+par(mfrow=c(2,2)); plot(m2); layout(1)
+
+anova(m1, m2)
+anova(m2)
+
+summary(m2)
+
+pred <- expand.grid(block="1",
+                    N=seq(-1, 1, by=0.1),
+                    K=seq(-1, 1, by=0.1))
+pred$mu <- predict(m2, newdata=pred)
+
+wireframe(mu~N+K, data=pred,
+          scales=list(arrows=FALSE),
+          zlab=list(expression(log(Branches+1)), rot=90),
+          drape=TRUE, cuts=20,
+          col.regions=colorRampPalette(
+              color=brewer.pal(n=11, name="Spectral"))(21))
+
+levelplot(mu~N+K, data=pred, aspect=1,
+          main=expression(log(Branches+1)),
+          col.regions=colorRampPalette(
+              color=brewer.pal(n=11, name="Spectral")))
+
+rm(list=ls())
+load("../data/coffeeFert.RData")
+ls()
+str(coffeeFert)
diff --git a/data/coffeeFert.RData b/data/coffeeFert.RData
new file mode 100644
index 0000000000000000000000000000000000000000..b86ba2ae621e613e72cb12359ed765231426b18f
GIT binary patch
literal 385
zcmb2|=3oE==C>iIy$(Bw?44_}lvjf_c9&40Vo+ALw%(Nmms<62bp@3qO9`_iGiP4R
z{qJLc(ElU1l=|G_sXR9xIEC}xnNuwP+;4{U%y)(B)4u8`38ip29-3gH|3urpQp<D8
zoeSS>*FSYtR!a7C^U3VKv}(P)NiAPP@&EeTOV1WOFTHE?-@NiyB46aLHKosf-GBM?
z?-qslP_Ml8H`R>JoY+v)Hd8WeM(#@K9Rd~S;|!*(u{pacBd^=D*K_Vkv&n3emtDJD
z!km6WcfZ&t*>VxLNxmHJxAp}}XTN9Mz3tHHjfc+7K9u?-`he93p3>(Z?pj|_+}HR+
z>I26|qot+34>&)~{!lLZNpOSq0i_RO_qX%yXa1}8r)}BuU7`unJJ$caUUutw>3S2}
zU$;#kJhX`2&-~=?VY?dpmm7KKsP`XF`&6JmW6R7rMYZ-Ecik<H);;05)9x}qE2`_z
tbS`thI)#Zf$uh^^ue#8oS?jl^I{it=9}h2&xl>Q7KRj*s!h?f>0RVs|yKn#i

literal 0
HcmV?d00001

diff --git a/man/cassavaYield.Rd b/man/cassavaYield.Rd
index 9cf4bd0..286b722 100644
--- a/man/cassavaYield.Rd
+++ b/man/cassavaYield.Rd
@@ -6,8 +6,8 @@
 \title{Cassava variety competition experiment}
 \format{a \code{data.frame} with 24 records and 3 variables.}
 \source{
-Frederico, P. (2009). Curso de Estatística Experimental (15th
-    ed.). Piracicaba, São Paulo: FEALQ. (page 93)
+Pimentel Gomes, F. (2009). Curso de Estatística Experimental
+    (15th ed.). Piracicaba, São Paulo: FEALQ. (page 93)
 }
 \usage{
 data(cassavaYield)
diff --git a/man/coffeeFert.Rd b/man/coffeeFert.Rd
new file mode 100644
index 0000000..9632a96
--- /dev/null
+++ b/man/coffeeFert.Rd
@@ -0,0 +1,52 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/legTools.R
+\docType{data}
+\name{coffeeFert}
+\alias{coffeeFert}
+\title{Number of dry branches in coffee trees as function of NPK}
+\format{a \code{data.frame} with 48 records and 5 variables.}
+\source{
+Pimentel Gomes, F. (2009). Curso de Estatística Experimental
+    (15th ed.). Piracicaba, São Paulo: FEALQ. (page 137)
+
+Malavolta, E.; Pimentel Gomes, F.; Coury, T. (1958). Estudos sobre a
+    alimentação mineral do cafeeiro (\emph{Coffea arabica} L.,
+    variedade Bourbon Vermelho). Piracicaba.
+}
+\usage{
+data(coffeeFert)
+}
+\description{
+These data are from a \eqn{2^3} factorial experiment
+    studing the effect of NPK fertilizaton on the number of dry
+    branches in coffee trees.
+
+\itemize{
+  \item \code{N} content of nitrogen in the fertilizer (low/high).
+  \item \code{P} content of phosphorus in the fertilizer (low/high).
+  \item \code{K} content of potassium in the fertilizer (low/high).
+  \item \code{block} an unordered factor representing the blocks
+    used.
+  \item \code{branches} an integer variable, the number of dry
+    branches in a coffee the.
+}
+}
+\details{
+The experiment was carried out in a randomized block design
+    with 6 blocks. In the book, the data is presented at squared root
+    scale.
+}
+\examples{
+library(lattice)
+library(latticeExtra)
+
+data(coffeeFert)
+str(coffeeFert)
+
+xyplot(branches~N|P, groups=K,
+       data=coffeeFert, type=c("p", "a"),
+       ylab=expression(Branches~(plant^{-1})),
+       xlab="Nutrient level")
+}
+\keyword{datasets}
+
diff --git a/man/cornYield.Rd b/man/cornYield.Rd
index 7c7d058..79457d6 100644
--- a/man/cornYield.Rd
+++ b/man/cornYield.Rd
@@ -6,8 +6,8 @@
 \title{Corn yield as function of fertilization with NPK}
 \format{a \code{data.frame} with 32 records and 4 variables.}
 \source{
-Frederico, P. (2009). Curso de Estatística Experimental (15th
-    ed.). Piracicaba, São Paulo: FEALQ. (page 115)
+Pimentel Gomes, F. (2009). Curso de Estatística Experimental
+    (15th ed.). Piracicaba, São Paulo: FEALQ. (page 115)
 }
 \usage{
 data(cornYield)
diff --git a/man/cornYield2.Rd b/man/cornYield2.Rd
index e6f18b1..c4f8252 100644
--- a/man/cornYield2.Rd
+++ b/man/cornYield2.Rd
@@ -6,14 +6,14 @@
 \title{Axial factorial NPK experiment with added treatments}
 \format{a \code{data.frame} with 9 records and 5 variables.}
 \source{
-Frederico, P. (2009). Curso de Estatística Experimental (15th
-    ed.). Piracicaba, São Paulo: FEALQ. (page 132)
+Pimentel Gomes, F. (2009). Curso de Estatística Experimental
+    (15th ed.). Piracicaba, São Paulo: FEALQ. (page 132)
 
 Simão, S. (1960). Estudo da planta e dos frutos da mangueira
     (\emph{Manginifera indica} L.). Piracicaba, 1960. Thesis.
 }
 \usage{
-data(sugarcaneYield4)
+data(cornYield2)
 }
 \description{
 These data are from an axial 3 factorial experiment
@@ -30,7 +30,7 @@ These data are from an axial 3 factorial experiment
 }
 }
 \details{
-The experiment was caried out in 16 different locations but
+The experiment was carried out in 16 different locations but
     only the mean by cell combinations were available in the text
     book.
 }
diff --git a/man/filterCake.Rd b/man/filterCake.Rd
index 6ddae71..8d859f0 100644
--- a/man/filterCake.Rd
+++ b/man/filterCake.Rd
@@ -6,8 +6,8 @@
 \title{Fertilization with filter cake and mineral}
 \format{a \code{data.frame} with 16 records and 4 variables.}
 \source{
-Frederico, P. (2009). Curso de Estatística Experimental (15th
-    ed.). Piracicaba, São Paulo: FEALQ. (page 120)
+Pimentel Gomes, F. (2009). Curso de Estatística Experimental
+    (15th ed.). Piracicaba, São Paulo: FEALQ. (page 120)
 }
 \usage{
 data(filterCake)
diff --git a/man/mangoAcidity.Rd b/man/mangoAcidity.Rd
index 85fb633..2185e70 100644
--- a/man/mangoAcidity.Rd
+++ b/man/mangoAcidity.Rd
@@ -6,14 +6,14 @@
 \title{Acidity of mango fruits by varieties, years and months}
 \format{a \code{data.frame} with 54 records and 6 variables.}
 \source{
-Frederico, P. (2009). Curso de Estatística Experimental (15th
-    ed.). Piracicaba, São Paulo: FEALQ. (page 132)
+Pimentel Gomes, F. (2009). Curso de Estatística Experimental
+    (15th ed.). Piracicaba, São Paulo: FEALQ. (page 132)
 
 Simão, S. (1960). Estudo da planta e dos frutos da mangueira
     (\emph{Manginifera indica} L.). Piracicaba, 1960. Thesis.
 }
 \usage{
-data(sugarcaneYield4)
+data(mangoAcidity)
 }
 \description{
 These data are from an observational study along 3 years
@@ -30,7 +30,6 @@ These data are from an observational study along 3 years
 }
 \examples{
 library(lattice)
-library(latticeExtra)
 
 data(mangoAcidity)
 str(mangoAcidity)
diff --git a/man/plowing.Rd b/man/plowing.Rd
index 30c69ca..3330108 100644
--- a/man/plowing.Rd
+++ b/man/plowing.Rd
@@ -6,8 +6,8 @@
 \title{Plowing level on corn yield}
 \format{a \code{data.frame} with 24 records and 3 variables.}
 \source{
-Frederico, P. (2009). Curso de Estatística Experimental (15th
-    ed.). Piracicaba, São Paulo: FEALQ. (page 91)
+Pimentel Gomes, F. (2009). Curso de Estatística Experimental
+    (15th ed.). Piracicaba, São Paulo: FEALQ. (page 91)
 }
 \usage{
 data(plowing)
diff --git a/man/potatoYield.Rd b/man/potatoYield.Rd
index 3a07526..39588d3 100644
--- a/man/potatoYield.Rd
+++ b/man/potatoYield.Rd
@@ -6,8 +6,8 @@
 \title{Potato variety competition experiment}
 \format{a \code{data.frame} with 32 records and 3 variables.}
 \source{
-Frederico, P. (2009). Curso de Estatística Experimental (15th
-    ed.). Piracicaba, São Paulo: FEALQ. (page 76)
+Pimentel Gomes, F. (2009). Curso de Estatística Experimental
+    (15th ed.). Piracicaba, São Paulo: FEALQ. (page 76)
 }
 \usage{
 data(potatoYield)
diff --git a/man/sugarcaneYield.Rd b/man/sugarcaneYield.Rd
index a79e78b..c5fa052 100644
--- a/man/sugarcaneYield.Rd
+++ b/man/sugarcaneYield.Rd
@@ -6,8 +6,8 @@
 \title{Sugarcane variety experiment}
 \format{a \code{data.frame} with 28 records and 3 variables.}
 \source{
-Frederico, P. (2009). Curso de Estatística Experimental (15th
-    ed.). Piracicaba, São Paulo: FEALQ. (page 92)
+Pimentel Gomes, F. (2009). Curso de Estatística Experimental
+    (15th ed.). Piracicaba, São Paulo: FEALQ. (page 92)
 }
 \usage{
 data(sugarcaneYield)
diff --git a/man/sugarcaneYield2.Rd b/man/sugarcaneYield2.Rd
index da824a9..40272aa 100644
--- a/man/sugarcaneYield2.Rd
+++ b/man/sugarcaneYield2.Rd
@@ -6,8 +6,8 @@
 \title{Sugarcane variety competition experiment}
 \format{a \code{data.frame} with 28 records and 3 variables.}
 \source{
-Frederico, P. (2009). Curso de Estatística Experimental (15th
-    ed.). Piracicaba, São Paulo: FEALQ. (page 96)
+Pimentel Gomes, F. (2009). Curso de Estatística Experimental
+    (15th ed.). Piracicaba, São Paulo: FEALQ. (page 96)
 }
 \usage{
 data(sugarcaneYield2)
diff --git a/man/sugarcaneYield3.Rd b/man/sugarcaneYield3.Rd
index 048af7a..48a9945 100644
--- a/man/sugarcaneYield3.Rd
+++ b/man/sugarcaneYield3.Rd
@@ -6,8 +6,8 @@
 \title{Sugarcane yield as function of fertilization strategy}
 \format{a \code{data.frame} with 28 records and 3 variables.}
 \source{
-Frederico, P. (2009). Curso de Estatística Experimental (15th
-    ed.). Piracicaba, São Paulo: FEALQ. (page 99)
+Pimentel Gomes, F. (2009). Curso de Estatística Experimental
+    (15th ed.). Piracicaba, São Paulo: FEALQ. (page 99)
 }
 \usage{
 data(sugarcaneYield3)
diff --git a/man/sugarcaneYield4.Rd b/man/sugarcaneYield4.Rd
index b0a2002..93ff7e0 100644
--- a/man/sugarcaneYield4.Rd
+++ b/man/sugarcaneYield4.Rd
@@ -6,8 +6,8 @@
 \title{Triple factorial NPK fertilization on sugar cane yield}
 \format{a \code{data.frame} with 54 records and 6 variables.}
 \source{
-Frederico, P. (2009). Curso de Estatística Experimental (15th
-    ed.). Piracicaba, São Paulo: FEALQ. (page 126)
+Pimentel Gomes, F. (2009). Curso de Estatística Experimental
+    (15th ed.). Piracicaba, São Paulo: FEALQ. (page 126)
 }
 \usage{
 data(sugarcaneYield4)
diff --git a/man/vinasseFert.Rd b/man/vinasseFert.Rd
index c52ece6..def3ee5 100644
--- a/man/vinasseFert.Rd
+++ b/man/vinasseFert.Rd
@@ -6,8 +6,8 @@
 \title{Fertilization with vinasse and mineral}
 \format{a \code{data.frame} with 16 records and 4 variables.}
 \source{
-Frederico, P. (2009). Curso de Estatística Experimental (15th
-    ed.). Piracicaba, São Paulo: FEALQ. (page 119)
+Pimentel Gomes, F. (2009). Curso de Estatística Experimental
+    (15th ed.). Piracicaba, São Paulo: FEALQ. (page 119)
 }
 \usage{
 data(vinasseFert)
diff --git a/man/wgPigs.Rd b/man/wgPigs.Rd
index e107692..5efbb50 100644
--- a/man/wgPigs.Rd
+++ b/man/wgPigs.Rd
@@ -6,8 +6,8 @@
 \title{Feeding type in pig weight gain}
 \format{a \code{data.frame} with 20 records and 2 variables.}
 \source{
-Frederico, P. (2009). Curso de Estatística Experimental (15th
-    ed.). Piracicaba, São Paulo: FEALQ. (page 62)
+Pimentel Gomes, F. (2009). Curso de Estatística Experimental
+    (15th ed.). Piracicaba, São Paulo: FEALQ. (page 62)
 }
 \usage{
 data(wgPigs)
diff --git a/man/wgPigs2.Rd b/man/wgPigs2.Rd
index 8ac1bb4..697f2ab 100644
--- a/man/wgPigs2.Rd
+++ b/man/wgPigs2.Rd
@@ -6,8 +6,8 @@
 \title{Age of castration in pig weight gain}
 \format{a \code{data.frame} with 16 records and 4 variables.}
 \source{
-Frederico, P. (2009). Curso de Estatística Experimental (15th
-    ed.). Piracicaba, São Paulo: FEALQ. (page 110)
+Pimentel Gomes, F. (2009). Curso de Estatística Experimental
+    (15th ed.). Piracicaba, São Paulo: FEALQ. (page 110)
 }
 \usage{
 data(wgPigs2)
-- 
GitLab