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

Add dataset of a 2^3 experiment with NPK on korn yield, Pimentel pg 115.

parent c68f9790
No related branches found
No related tags found
No related merge requests found
...@@ -365,7 +365,7 @@ NULL ...@@ -365,7 +365,7 @@ NULL
#' \item \code{yield} sugarcane yield (kg/plot). #' \item \code{yield} sugarcane yield (kg/plot).
#' } #' }
#' #'
#' @details The levels of fetilization are in fact a combination of a #' @details The levels of fertilization are in fact a combination of a
#' \eqn{3^2} factorial experiment but not all cells are present, so #' \eqn{3^2} factorial experiment but not all cells are present, so
#' this is a (intentional) incomplete three factorial #' this is a (intentional) incomplete three factorial
#' experiment. The factors used were limestone (A: present, a: #' experiment. The factors used were limestone (A: present, a:
...@@ -496,3 +496,80 @@ NULL ...@@ -496,3 +496,80 @@ NULL
#' test=adjusted(type="single-step")) #' test=adjusted(type="single-step"))
#' #'
NULL NULL
#' @name kornYield
#'
#' @title Korn yield as function of fertilization with NPK
#'
#' @description These data are from an \eqn{2^3} factorial experiment
#' studing the effect of Nitrogen (N), Phosporus (P) and Potassium
#' (K) on korn yield in a randomized block design.
#'
#' \itemize{
#' \item \code{block} a factor with 4 levels.
#' \item \code{N} low (-1) and high (+1) levels of nitrogen.
#' \item \code{P} low (-1) and high (+1) levels of phosporus.
#' \item \code{K} low (-1) and high (+1) levels of potassium.
#' \item \code{yield} korn yield (ton/ha).
#' }
#'
#' @docType data
#'
#' @keywords datasets
#'
#' @usage data(kornYield)
#'
#' @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)
#'
#' @examples
#'
#' 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
##----------------------------------------------------------------------
## Data generation.
kornYield <- expand.grid(block=gl(4, 1), N=c(-1,1), P=c(-1,1),
K=c(-1,1), KEEP.OUT.ATTRS=FALSE)
kornYield$yield <- c(1.32, 2.12, 1.75, 2.35, 1.80, 2.20, 2.95, 2.96,
1.66, 2.66, 1.73, 2.58, 1.72, 3.85, 2.62, 3.00,
2.58, 3.56, 2.86, 2.75, 2.72, 3.20, 2.25, 2.75,
2.26, 2.08, 1.95, 2.70, 2.95, 3.28, 2.40, 3.35)
str(kornYield)
save(kornYield, file="../data/kornYield.RData")
##----------------------------------------------------------------------
## Examples.
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")))
rm(list=ls())
load("../data/kornYield.RData")
ls()
str(kornYield)
File added
No preview for this file type
...@@ -2,18 +2,31 @@ ...@@ -2,18 +2,31 @@
;;; This format is meant to be slightly human-readable; ;;; This format is meant to be slightly human-readable;
;;; nevertheless, you probably don't want to edit it. ;;; nevertheless, you probably don't want to edit it.
;;; -*- End Of Bookmark File Format Version Stamp -*- ;;; -*- End Of Bookmark File Format Version Stamp -*-
(#1=(#("wgpigs2" 0 7 (#1=(#("kornYield" 0 9
(bmkp-full-record #1#)) (bmkp-full-record #1#))
(filename . "~/GitLab/legTools/R/legTools.R") (filename . "~/GitLab/legTools/R/legTools.R")
(buffer-name . "legTools.R") (buffer-name . "legTools.R")
(front-context-string . "@name wgpigs2\n#'") (front-context-string . "@name kornYield\n")
(rear-context-string . "an)\n#'\nNULL\n\n#' ") (rear-context-string . "\"))\n#'\nNULL\n\n#' ")
(front-context-region-string) (front-context-region-string)
(rear-context-region-string) (rear-context-region-string)
(visits . 0) (visits . 0)
(time . #2=(22014 2449 877392 862000)) (time . #2=(22014 6386 355822 993000))
(created . #2#) (created . #2#)
(position . 14008)) (position . 16336))
#1=(#("wgpigs2" 0 7
(bmkp-full-record #1#))
(end-position . 14001)
(filename . "~/GitLab/legTools/R/legTools.R")
(buffer-name . "legTools.R")
(front-context-string . "@name wgpigs2\n#'")
(rear-context-string . "an)\n#'\nNULL\n\n#' ")
(front-context-region-string)
(rear-context-region-string)
(visits . 3)
(time 22014 6373 782337 593000)
(created 22014 2449 877392 862000)
(position . 14001))
#1=(#("sugarcaneYield3" 0 15 #1=(#("sugarcaneYield3" 0 15
(bmkp-full-record #1#)) (bmkp-full-record #1#))
(filename . "~/GitLab/legTools/R/legTools.R") (filename . "~/GitLab/legTools/R/legTools.R")
...@@ -22,9 +35,9 @@ ...@@ -22,9 +35,9 @@
(rear-context-string . "an)\n#'\nNULL\n\n#' ") (rear-context-string . "an)\n#'\nNULL\n\n#' ")
(front-context-region-string) (front-context-region-string)
(rear-context-region-string) (rear-context-region-string)
(visits . 0) (visits . 2)
(time . #2=(22014 2438 565160 262000)) (time 22014 6373 622489 1000)
(created . #2#) (created 22014 2438 565160 262000)
(position . 11050)) (position . 11050))
#1=(#("sugarcaneYield2" 0 15 #1=(#("sugarcaneYield2" 0 15
(bmkp-full-record #1#)) (bmkp-full-record #1#))
...@@ -34,9 +47,9 @@ ...@@ -34,9 +47,9 @@
(rear-context-string . "y\")\n#'\nNULL\n\n#' ") (rear-context-string . "y\")\n#'\nNULL\n\n#' ")
(front-context-region-string) (front-context-region-string)
(rear-context-region-string) (rear-context-region-string)
(visits . 0) (visits . 1)
(time . #2=(22014 2428 365189 950000)) (time 22014 6373 470955 812000)
(created . #2#) (created 22014 2428 365189 950000)
(position . 9217)) (position . 9217))
#1=(#("sugarcaneYield" 0 14 #1=(#("sugarcaneYield" 0 14
(bmkp-full-record #1#)) (bmkp-full-record #1#))
...@@ -46,9 +59,9 @@ ...@@ -46,9 +59,9 @@
(rear-context-string . "y\")\n#'\nNULL\n\n#' ") (rear-context-string . "y\")\n#'\nNULL\n\n#' ")
(front-context-region-string) (front-context-region-string)
(rear-context-region-string) (rear-context-region-string)
(visits . 0) (visits . 1)
(time . #2=(22014 2414 357030 236000)) (time 22014 6373 318366 504000)
(created . #2#) (created 22014 2414 357030 236000)
(position . 8152)) (position . 8152))
#1=(#("cassavaYield" 0 12 #1=(#("cassavaYield" 0 12
(bmkp-full-record #1#)) (bmkp-full-record #1#))
...@@ -58,9 +71,9 @@ ...@@ -58,9 +71,9 @@
(rear-context-string . "2))\n#'\nNULL\n\n#' ") (rear-context-string . "2))\n#'\nNULL\n\n#' ")
(front-context-region-string) (front-context-region-string)
(rear-context-region-string) (rear-context-region-string)
(visits . 0) (visits . 1)
(time . #2=(22014 2401 421345 289000)) (time 22014 6373 167010 949000)
(created . #2#) (created 22014 2401 421345 289000)
(position . 6963)) (position . 6963))
#1=(#("defoliation" 0 11 #1=(#("defoliation" 0 11
(bmkp-full-record #1#)) (bmkp-full-record #1#))
...@@ -70,9 +83,9 @@ ...@@ -70,9 +83,9 @@
(rear-context-string . "l\")\n#'\nNULL\n\n#' ") (rear-context-string . "l\")\n#'\nNULL\n\n#' ")
(front-context-region-string) (front-context-region-string)
(rear-context-region-string) (rear-context-region-string)
(visits . 0) (visits . 1)
(time . #2=(22014 2388 893464 613000)) (time 22014 6373 30840 723000)
(created . #2#) (created 22014 2388 893464 613000)
(position . 3566)) (position . 3566))
#1=(#("plowing" 0 7 #1=(#("plowing" 0 7
(bmkp-full-record #1#)) (bmkp-full-record #1#))
...@@ -82,9 +95,9 @@ ...@@ -82,9 +95,9 @@
(rear-context-string . "y\")\n#'\nNULL\n\n#' ") (rear-context-string . "y\")\n#'\nNULL\n\n#' ")
(front-context-region-string) (front-context-region-string)
(rear-context-region-string) (rear-context-region-string)
(visits . 0) (visits . 1)
(time . #2=(22014 2377 645195 878000)) (time 22014 6372 878551 941000)
(created . #2#) (created 22014 2377 645195 878000)
(position . 2330)) (position . 2330))
#1=(#("potatoYield" 0 11 #1=(#("potatoYield" 0 11
(bmkp-full-record #1#)) (bmkp-full-record #1#))
...@@ -94,9 +107,9 @@ ...@@ -94,9 +107,9 @@
(rear-context-string . "e\")\n#'\nNULL\n\n#' ") (rear-context-string . "e\")\n#'\nNULL\n\n#' ")
(front-context-region-string) (front-context-region-string)
(rear-context-region-string) (rear-context-region-string)
(visits . 0) (visits . 1)
(time . #2=(22014 2364 877635 749000)) (time 22014 6372 742266 92000)
(created . #2#) (created 22014 2364 877635 749000)
(position . 1285)) (position . 1285))
#1=(#("wgpigs" 0 6 #1=(#("wgpigs" 0 6
(bmkp-full-record #1#)) (bmkp-full-record #1#))
...@@ -106,9 +119,9 @@ ...@@ -106,9 +119,9 @@
(rear-context-string . "gTools\nNULL\n\n#' ") (rear-context-string . "gTools\nNULL\n\n#' ")
(front-context-region-string) (front-context-region-string)
(rear-context-region-string) (rear-context-region-string)
(visits . 0) (visits . 2)
(time . #2=(22014 2268 166496 375000)) (time 22014 6374 126563 478000)
(created . #2#) (created 22014 2268 166496 375000)
(position . 219)) (position . 219))
#1=(#("legTools.R" 0 10 #1=(#("legTools.R" 0 10
(bmkp-full-record #1#)) (bmkp-full-record #1#))
...@@ -120,9 +133,9 @@ ...@@ -120,9 +133,9 @@
(rear-context-string . "ype package\n##' ") (rear-context-string . "ype package\n##' ")
(front-context-region-string) (front-context-region-string)
(rear-context-region-string) (rear-context-region-string)
(visits . 0) (visits . 3)
(time . #2=(22014 2255 246295 352000)) (time 22014 6373 950617 320000)
(created . #2#) (created 22014 2255 246295 352000)
(position . 195)) (position . 195))
#1=(#("DESCRIPTION" 0 11 #1=(#("DESCRIPTION" 0 11
(bmkp-full-record #1#)) (bmkp-full-record #1#))
......
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/legTools.R
\docType{data}
\name{kornYield}
\alias{kornYield}
\title{Korn 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)
}
\usage{
data(kornYield)
}
\description{
These data are from an \eqn{2^3} factorial experiment
studing the effect of Nitrogen (N), Phosporus (P) and Potassium
(K) on korn yield in a randomized block design.
\itemize{
\item \code{block} a factor with 4 levels.
\item \code{N} low (-1) and high (+1) levels of nitrogen.
\item \code{P} low (-1) and high (+1) levels of phosporus.
\item \code{K} low (-1) and high (+1) levels of potassium.
\item \code{yield} korn yield (ton/ha).
}
}
\examples{
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")))
}
\keyword{datasets}
...@@ -29,7 +29,7 @@ These data are from an experiment done by the engineer ...@@ -29,7 +29,7 @@ These data are from an experiment done by the engineer
} }
\examples{ \examples{
library(lattice) library(lattice)
data(potatoyield) data(plowing)
xyplot(yield~plow|block, data=plowing, type=c("p", "a"), xyplot(yield~plow|block, data=plowing, type=c("p", "a"),
ylab=expression(Yield~(t~ha^{-1})), ylab=expression(Yield~(t~ha^{-1})),
......
% Generated by roxygen2 (4.1.1): do not edit by hand % Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/legTools.R % Please edit documentation in R/legTools.R
\docType{data} \docType{data}
\name{potatoyield} \name{potatoYield}
\alias{potatoyield} \alias{potatoYield}
\title{Potato variety competition experiment} \title{Potato variety competition experiment}
\format{a \code{data.frame} with 32 records and 3 variables.} \format{a \code{data.frame} with 32 records and 3 variables.}
\source{ \source{
...@@ -10,7 +10,7 @@ Frederico, P. (2009). Curso de Estatística Experimental (15th ...@@ -10,7 +10,7 @@ Frederico, P. (2009). Curso de Estatística Experimental (15th
ed.). Piracicaba, São Paulo: FEALQ. (page 76) ed.). Piracicaba, São Paulo: FEALQ. (page 76)
} }
\usage{ \usage{
data(potatoyield) data(potatoYield)
} }
\description{ \description{
These data are from an experiment done by the engineer These data are from an experiment done by the engineer
...@@ -27,9 +27,9 @@ These data are from an experiment done by the engineer ...@@ -27,9 +27,9 @@ These data are from an experiment done by the engineer
} }
\examples{ \examples{
library(lattice) library(lattice)
data(potatoyield) data(potatoYield)
plot(yield~variety, data=potatoyield, plot(yield~variety, data=potatoYield,
groups=block, type="o", groups=block, type="o",
ylab=expression(Yield~(t~ha^{-1})), ylab=expression(Yield~(t~ha^{-1})),
xlab="Variety") xlab="Variety")
......
...@@ -31,7 +31,7 @@ These data are from an experiment done in a latin square ...@@ -31,7 +31,7 @@ These data are from an experiment done in a latin square
} }
} }
\details{ \details{
The levels of fetilization are in fact a combination of a The levels of fertilization are in fact a combination of a
\eqn{3^2} factorial experiment but not all cells are present, so \eqn{3^2} factorial experiment but not all cells are present, so
this is a (intentional) incomplete three factorial this is a (intentional) incomplete three factorial
experiment. The factors used were limestone (A: present, a: experiment. The factors used were limestone (A: present, a:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment