diff --git a/R/legTools.R b/R/legTools.R index f062b1ccfbc8bc65fdea38a960de9382b9de6c0e..963ddcc7185899a55a9d08ef76291ceefa5010c2 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 0000000000000000000000000000000000000000..be78f45e285e2a4c57869c6660cded7523392a86 --- /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 Binary files /dev/null and b/data/vinasseFert.RData differ diff --git a/man/vinasseFert.Rd b/man/vinasseFert.Rd new file mode 100644 index 0000000000000000000000000000000000000000..981cc37232a997c214223a387b0cb266ea5386a4 --- /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} +