From aa9a860dcecaaf2154a1c9e230a5880ca2d41274 Mon Sep 17 00:00:00 2001 From: Walmes Zeviani <walmeszeviani@gmail.com> Date: Sun, 20 Sep 2015 11:25:27 -0300 Subject: [PATCH] Add dataset of a 2^2 RBD experiment, Pimentel pg 219. --- R/legTools.R | 77 +++++++++++++++++++++++++++++++++++------ data-raw/vinasseFert.R | 45 ++++++++++++++++++++++++ data/vinasseFert.RData | Bin 0 -> 312 bytes man/vinasseFert.Rd | 56 ++++++++++++++++++++++++++++++ 4 files changed, 168 insertions(+), 10 deletions(-) create mode 100644 data-raw/vinasseFert.R create mode 100644 data/vinasseFert.RData create mode 100644 man/vinasseFert.Rd diff --git a/R/legTools.R b/R/legTools.R index f062b1c..963ddcc 100644 --- a/R/legTools.R +++ b/R/legTools.R @@ -528,48 +528,105 @@ NULL #' #' library(lattice) #' library(latticeExtra) -#' +#' #' data(kornYield) #' str(kornYield) -#' +#' #' xyplot(yield~N|P, groups=K, #' data=kornYield, type=c("p", "a"), #' ylab=expression(Yield~(ton~ha^{-1})), #' xlab="Nutrient level") -#' +#' #' xyplot(yield~N, groups=interaction(P, K), #' data=kornYield, type=c("p", "a"), #' auto.key=list(columns=2), #' ylab=expression(Yield~(ton~ha^{-1})), #' xlab="Nutrient level") -#' +#' #' m0 <- lm(yield~block+(N+P+K)^3, data=kornYield) #' par(mfrow=c(2,2)); plot(m0); layout(1) #' anova(m0) -#' +#' #' m1 <- update(m0, .~block+N+K) #' par(mfrow=c(2,2)); plot(m1); layout(1) -#' +#' #' anova(m0, m1) #' anova(m1) -#' +#' #' summary(m1) -#' +#' #' pred <- expand.grid(block="1", #' N=seq(-1, 1, by=0.1), #' K=seq(-1, 1, by=0.1)) #' pred$mu <- predict(m1, newdata=pred) -#' +#' #' wireframe(mu~N+K, data=pred, #' scales=list(arrows=FALSE), #' zlab=list(expression(Yield~(ton~ha^{-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(Yield~(ton~ha^{-1})), #' col.regions=colorRampPalette( #' color=brewer.pal(n=11, name="Spectral"))) #' NULL + +#' @name vinasseFert +#' +#' @title Fertilization with vinasse and mineral +#' +#' @description These data are from an \eqn{2^2} factorial experiment +#' studing the effect of fertilizaton with vinasse (organic font) +#' and complete mineral fertilization. +#' +#' \itemize{ +#' \item \code{block} a factor with 4 levels. +#' \item \code{mineral} low (-1) and high (+1) levels of mineral +#' fertilization. +#' \item \code{vinasse} low (-1) and high (+1) levels of fetilization +#' with vinasse. +#' \item \code{y} some response variable. The text book doesn't give +#' any information. +#' } +#' +#' @docType data +#' +#' @keywords datasets +#' +#' @usage data(vinasseFert) +#' +#' @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) +#' +#' @examples +#' +#' library(lattice) +#' library(latticeExtra) +#' +#' data(vinasseFert) +#' str(vinasseFert) +#' +#' xyplot(y~vinasse, groups=mineral, +#' auto.key=list(title="Mineral", columns=2), +#' data=vinasseFert, type=c("p", "a"), +#' ylab="y", +#' xlab="Vinasse level") +#' +#' m0 <- lm(y~block+(vinasse+mineral)^2, data=vinasseFert) +#' par(mfrow=c(2,2)); plot(m0); layout(1) +#' anova(m0) +#' +#' m1 <- update(m0, .~block+vinasse) +#' par(mfrow=c(2,2)); plot(m1); layout(1) +#' +#' anova(m0, m1) +#' anova(m1) +#' +#' summary(m1) +#' +NULL diff --git a/data-raw/vinasseFert.R b/data-raw/vinasseFert.R new file mode 100644 index 0000000..be78f45 --- /dev/null +++ b/data-raw/vinasseFert.R @@ -0,0 +1,45 @@ +##---------------------------------------------------------------------- +## Data generation. + +vinasseFert <- expand.grid(block=gl(4, 1), mineral=c(-1, 1), + vinasse=c(-1, 1), KEEP.OUT.ATTRS=FALSE) + +vinasseFert$y <- c(0.020, 0.630, 0.110, 0.115, 0.020, 2.005, 0.700, + 1.120, 3.040, 4.760, 5.860, 5.520, 5.150, 4.770, + 3.960, 5.230) + +str(vinasseFert) + +save(vinasseFert, file="../data/vinasseFert.RData") + +##---------------------------------------------------------------------- +## Examples. + +library(lattice) +library(latticeExtra) + +data(vinasseFert) +str(vinasseFert) + +xyplot(y~vinasse, groups=mineral, + auto.key=list(title="Mineral", columns=2), + data=vinasseFert, type=c("p", "a"), + ylab="y", + xlab="Vinasse level") + +m0 <- lm(y~block+(vinasse+mineral)^2, data=vinasseFert) +par(mfrow=c(2,2)); plot(m0); layout(1) +anova(m0) + +m1 <- update(m0, .~block+vinasse) +par(mfrow=c(2,2)); plot(m1); layout(1) + +anova(m0, m1) +anova(m1) + +summary(m1) + +rm(list=ls()) +load("../data/vinasseFert.RData") +ls() +str(vinasseFert) diff --git a/data/vinasseFert.RData b/data/vinasseFert.RData new file mode 100644 index 0000000000000000000000000000000000000000..68936a5086a615fd434fb664c2fe78942a8ab486 GIT binary patch literal 312 zcmb2|=3oE=X6~X+gGXHtk`fXUk`mIAk`j{Gj3Q?=uqZQgGpkQ{rg!>`w~n4)skg3H zVnTu#+ezlkI0apXFt$rvA`KmrPq}aG(pBH8W4c@-%ZNK<%0+==22F-Ni9Et4!V!~; z8}eGMd9!k&l8QX*1Sfpu@A&Dk>9@T>1Eb!pc?`ZQ>yqv|uCzU}>u{adRp;-eN>{)6 zo9vT&)qiozedeX##dP+aOO583T%Pb?6Km%Udv9ju-~H>OpO&%gD}2DgV%Q|pqWFpL zkw7h9l2Sr1pOUd-!n9_CDd+d|ohcA#eBs`IY|oK9Azw-k%$hQJ{v6(?8=j{<TPmjd z?7)r-E?nN?Q#06##GX!neUOJ$HFg=B!pHyr|MLs9p7}2saG59EE6H<FT$Eq{H?zv! QKg<lrOOr2XGczy%0G0ZH>;M1& literal 0 HcmV?d00001 diff --git a/man/vinasseFert.Rd b/man/vinasseFert.Rd new file mode 100644 index 0000000..981cc37 --- /dev/null +++ b/man/vinasseFert.Rd @@ -0,0 +1,56 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/legTools.R +\docType{data} +\name{vinasseFert} +\alias{vinasseFert} +\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) +} +\usage{ +data(vinasseFert) +} +\description{ +These data are from an \eqn{2^2} factorial experiment + studing the effect of fertilizaton with vinasse (organic font) + and complete mineral fertilization. + +\itemize{ + \item \code{block} a factor with 4 levels. + \item \code{mineral} low (-1) and high (+1) levels of mineral + fertilization. + \item \code{vinasse} low (-1) and high (+1) levels of fetilization + with vinasse. + \item \code{y} some response variable. The text book doesn't give + any information. +} +} +\examples{ +library(lattice) +library(latticeExtra) + +data(vinasseFert) +str(vinasseFert) + +xyplot(y~vinasse, groups=mineral, + auto.key=list(title="Mineral", columns=2), + data=vinasseFert, type=c("p", "a"), + ylab="y", + xlab="Vinasse level") + +m0 <- lm(y~block+(vinasse+mineral)^2, data=vinasseFert) +par(mfrow=c(2,2)); plot(m0); layout(1) +anova(m0) + +m1 <- update(m0, .~block+vinasse) +par(mfrow=c(2,2)); plot(m1); layout(1) + +anova(m0, m1) +anova(m1) + +summary(m1) +} +\keyword{datasets} + -- GitLab