Skip to content
Snippets Groups Projects
Commit 9bb4cea9 authored by Walmes Zeviani's avatar Walmes Zeviani
Browse files

Add dataset from a LSD with a incomplete factorial, Pimentel pg 99.

parent 98c894a8
No related branches found
No related tags found
No related merge requests found
......@@ -343,3 +343,79 @@ NULL
#' aggregate(yield~variety, data=sugarcaneYield2, FUN=mean)
#'
NULL
#' @name sugarcaneYield3
#'
#' @title Sugarcane yield as function of fertilization strategy
#'
#' @description These data are from an experiment done in a latin square
#' design of size 5. Sugarcane yield (kg/plot) was recorded in each
#' experimental unit.
#'
#' \itemize{
#' \item \code{row} the rows of the latin square that controls in
#' one dimention. A categorical unordered factor with 6 levels.
#' \item \code{col} the columns of the latin square that controls in
#' one dimention perpendicular to the previus. A categorical
#' unordered factor with 6 levels.
#' \item \code{fertil} a categorical unordered factor with 6
#' levels that is the fertilization strategy applied. These levels
#' are a result of treatment cells in a three incomplete factorial
#' arrangrment. See detais for more information.
#' \item \code{yield} sugarcane yield (kg/plot).
#' }
#'
#' @details The levels of fetilization are in fact a combination of a
#' \eqn{3^2} factorial experiment but not all cells are present, so
#' this is a (intentional) incomplete three factorial
#' experiment. The factors used were limestone (A: present, a:
#' absent), \emph{Crotalaria juncae} (B: present, b: absent) and
#' fertilizer (C: present, c: absent). Therefore, the level ABC
#' means that all three factors are present. To access the effect of
#' each factor and interactions can be applied contrasts.
#'
#' @docType data
#'
#' @keywords datasets
#'
#' @usage data(sugarcaneYield3)
#'
#' @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)
#'
#' @examples
#'
#' library(lattice)
#' library(latticeExtra)
#'
#' xyplot(yield~fertil|col, groups=row, data=sugarcaneYield3,
#' ylab=expression(Yield~(kg~plot^{-1})),
#' xlab="Fertilization", scales=list(x=list(rot=90)))
#'
#' ## display.brewer.all()
#'
#' levelplot(yield~row+col,
#' data=sugarcaneYield3, aspect="iso",
#' xlab="Row", ylab="Column",
#' main=expression(Yield~(kg~plot^{-1})),
#' col.regions=colorRampPalette(
#' colors=brewer.pal(n=11, name="Spectral")))+
#' layer(with(sugarcaneYield3,
#' panel.text(x=row, y=col,
#' label=sprintf("%s\n%0.2f", fertil, yield))))
#'
#' aggregate(yield~row, data=sugarcaneYield3, FUN=mean)
#' aggregate(yield~col, data=sugarcaneYield3, FUN=mean)
#' aggregate(yield~fertil, data=sugarcaneYield3, FUN=mean)
#'
#' ## The incomplete factorial structure.
#' X <- mapply(FUN=grepl, c("A", "B", "C"),
#' MoreArgs=list(x=sugarcaneYield3$fertil))*1
#' sugarcaneYield3 <- cbind(sugarcaneYield3, as.data.frame(X))
#'
#' ftable(with(sugarcaneYield3, tapply(yield, list(B, A, C), FUN=mean)))
#' aggregate(yield~A+B+C, data=sugarcaneYield3, FUN=mean)
#'
NULL
##----------------------------------------------------------------------
## Data generation.
sugarcaneYield3 <- read.table("http://www.leg.ufpr.br/~walmes/data/pimentel_crotalaria.txt",
header=TRUE, sep="\t")
names(sugarcaneYield3) <- c("row", "col", "fertil", "yield")
sugarcaneYield3 <- transform(sugarcaneYield3, row=factor(row),
col=factor(col))
aggregate(yield~fertil, data=sugarcaneYield3, FUN=mean)
levels(sugarcaneYield3$fertil) <- c("ABC", "ABc", "Ab", "aBC", "aBc", "ab")
str(sugarcaneYield3)
sugarcaneYield3 <- sugarcaneYield3[with(sugarcaneYield3, order(row, col)),]
save(sugarcaneYield3, file="../data/sugarcaneYield3.RData")
##----------------------------------------------------------------------
## Examples.
library(lattice)
library(latticeExtra)
xyplot(yield~fertil|col, groups=row, data=sugarcaneYield3,
ylab=expression(Yield~(kg~plot^{-1})),
xlab="Fertilization", scales=list(x=list(rot=90)))
## display.brewer.all()
levelplot(yield~row+col,
data=sugarcaneYield3, aspect="iso",
xlab="Row", ylab="Column",
main=expression(Yield~(kg~plot^{-1})),
col.regions=colorRampPalette(
colors=brewer.pal(n=11, name="Spectral")))+
layer(with(sugarcaneYield3,
panel.text(x=row, y=col,
label=sprintf("%s\n%0.2f", fertil, yield))))
aggregate(yield~row, data=sugarcaneYield3, FUN=mean)
aggregate(yield~col, data=sugarcaneYield3, FUN=mean)
aggregate(yield~fertil, data=sugarcaneYield3, FUN=mean)
## The incomplete factorial structure.
X <- mapply(FUN=grepl, c("A", "B", "C"),
MoreArgs=list(x=sugarcaneYield3$fertil))*1
sugarcaneYield3 <- cbind(sugarcaneYield3, as.data.frame(X))
ftable(with(sugarcaneYield3, tapply(yield, list(B, A, C), FUN=mean)))
aggregate(yield~A+B+C, data=sugarcaneYield3, FUN=mean)
rm(list=ls())
load("../data/sugarcaneYield3.RData")
ls()
str(sugarcaneYield3)
File added
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/legTools.R
\docType{data}
\name{sugarcaneYield2}
\alias{sugarcaneYield2}
\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)
}
\usage{
data(sugarcaneYield2)
}
\description{
These data are from an experiment done in a latin square
design of size 5. Sugarcane yield (kg/plot) was recorded in each
experimental unit.
\itemize{
\item \code{row} the rows of the latin square that controls in
one dimention. A categorical unordered factor with 5 levels.
\item \code{col} the columns of the latin square that controls in
one dimention perpendicular to the previus. A categorical
unordered factor with 5 levels.
\item \code{variety} a categorical unordered factor with 5
levels.
\item \code{yield} sugarcane yield (kg/plot).
}
}
\examples{
library(lattice)
library(latticeExtra)
xyplot(yield~variety|col, groups=row, data=sugarcaneYield2,
ylab=expression(Yield~(kg~plot^{-1})),
xlab="Variety")
## display.brewer.all()
levelplot(yield~row+col,
data=sugarcaneYield2, aspect="iso",
xlab="Row", ylab="Column",
main=expression(Yield~(kg~plot^{-1})),
col.regions=colorRampPalette(
colors=brewer.pal(n=11, name="Spectral")))+
layer(with(sugarcaneYield2,
panel.text(x=row, y=col,
label=paste(variety, yield))))
aggregate(yield~row, data=sugarcaneYield2, FUN=mean)
aggregate(yield~col, data=sugarcaneYield2, FUN=mean)
aggregate(yield~variety, data=sugarcaneYield2, FUN=mean)
}
\keyword{datasets}
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/legTools.R
\docType{data}
\name{sugarcaneYield3}
\alias{sugarcaneYield3}
\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)
}
\usage{
data(sugarcaneYield3)
}
\description{
These data are from an experiment done in a latin square
design of size 5. Sugarcane yield (kg/plot) was recorded in each
experimental unit.
\itemize{
\item \code{row} the rows of the latin square that controls in
one dimention. A categorical unordered factor with 6 levels.
\item \code{col} the columns of the latin square that controls in
one dimention perpendicular to the previus. A categorical
unordered factor with 6 levels.
\item \code{fertil} a categorical unordered factor with 6
levels that is the fertilization strategy applied. These levels
are a result of treatment cells in a three incomplete factorial
arrangrment. See detais for more information.
\item \code{yield} sugarcane yield (kg/plot).
}
}
\details{
The levels of fetilization are in fact a combination of a
\eqn{3^2} factorial experiment but not all cells are present, so
this is a (intentional) incomplete three factorial
experiment. The factors used were limestone (A: present, a:
absent), \emph{Crotalaria juncae} (B: present, b: absent) and
fertilizer (C: present, c: absent). Therefore, the level ABC
means that all three factors are present. To access the effect of
each factor and interactions can be applied contrasts.
}
\examples{
library(lattice)
library(latticeExtra)
xyplot(yield~fertil|col, groups=row, data=sugarcaneYield3,
ylab=expression(Yield~(kg~plot^{-1})),
xlab="Fertilization", scales=list(x=list(rot=90)))
## display.brewer.all()
levelplot(yield~row+col,
data=sugarcaneYield3, aspect="iso",
xlab="Row", ylab="Column",
main=expression(Yield~(kg~plot^{-1})),
col.regions=colorRampPalette(
colors=brewer.pal(n=11, name="Spectral")))+
layer(with(sugarcaneYield3,
panel.text(x=row, y=col,
label=sprintf("\%s\\n\%0.2f", fertil, yield))))
aggregate(yield~row, data=sugarcaneYield3, FUN=mean)
aggregate(yield~col, data=sugarcaneYield3, FUN=mean)
aggregate(yield~fertil, data=sugarcaneYield3, FUN=mean)
## The incomplete factorial structure.
X <- mapply(FUN=grepl, c("A", "B", "C"),
MoreArgs=list(x=sugarcaneYield3$fertil))*1
sugarcaneYield3 <- cbind(sugarcaneYield3, as.data.frame(X))
ftable(with(sugarcaneYield3, tapply(yield, list(B, A, C), FUN=mean)))
aggregate(yield~A+B+C, data=sugarcaneYield3, FUN=mean)
}
\keyword{datasets}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment