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

Files resulted of 'check()'.

parent 3a07855a
Branches
No related tags found
No related merge requests found
...@@ -41,10 +41,25 @@ build(manual = TRUE, vignettes = FALSE) ...@@ -41,10 +41,25 @@ build(manual = TRUE, vignettes = FALSE)
# build the binary version for windows (not used) # build the binary version for windows (not used)
# build_win() # build_win()
##----------------------------------------------------------------------
## Test installation.
## Test install with install.packages ## Test install with install.packages
pkg <- paste0("../legTools_", packageVersion("legTools"), ".tar.gz") pkg <- paste0("../legTools_", packageVersion("legTools"), ".tar.gz")
install.packages(pkg, repos = NULL) install.packages(pkg, repos = NULL)
## Test using devtools::install_git().
libTest <- "~/R/"
if (file.exists(libTest)){
file.remove(libTest)
}
dir.create(path=libTest)
.libPaths(new=libTest)
install_git(url="http://git.leg.ufpr.br/leg/legTools.git",
branch="issue#9")
##====================================================================== ##======================================================================
## Sending package tarballs and manual to remote server to be ## Sending package tarballs and manual to remote server to be
## downloadable ## downloadable
......
% 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{kornYield} \name{cornYield}
\alias{kornYield} \alias{cornYield}
\title{Korn yield as function of fertilization with NPK} \title{Corn yield as function of fertilization with NPK}
\format{a \code{data.frame} with 32 records and 4 variables.} \format{a \code{data.frame} with 32 records and 4 variables.}
\source{ \source{
Frederico, P. (2009). Curso de Estatística Experimental (15th Frederico, P. (2009). Curso de Estatística Experimental (15th
ed.). Piracicaba, São Paulo: FEALQ. (page 115) ed.). Piracicaba, São Paulo: FEALQ. (page 115)
} }
\usage{ \usage{
data(kornYield) data(cornYield)
} }
\description{ \description{
These data are from an \eqn{2^3} factorial experiment These data are from an \eqn{2^3} factorial experiment
studing the effect of Nitrogen (N), Phosporus (P) and Potassium studing the effect of Nitrogen (N), Phosporus (P) and Potassium
(K) on korn yield in a randomized block design. (K) on corn yield in a randomized block design.
\itemize{ \itemize{
\item \code{block} a factor with 4 levels. \item \code{block} a factor with 4 levels.
\item \code{N} low (-1) and high (+1) levels of nitrogen. \item \code{N} low (-1) and high (+1) levels of nitrogen.
\item \code{P} low (-1) and high (+1) levels of phosporus. \item \code{P} low (-1) and high (+1) levels of phosporus.
\item \code{K} low (-1) and high (+1) levels of potassium. \item \code{K} low (-1) and high (+1) levels of potassium.
\item \code{yield} korn yield (ton/ha). \item \code{yield} corn yield (ton/ha).
} }
} }
\examples{ \examples{
library(lattice) library(lattice)
library(latticeExtra) library(latticeExtra)
data(kornYield) data(cornYield)
str(kornYield) str(cornYield)
xyplot(yield~N|P, groups=K, xyplot(yield~N|P, groups=K,
data=kornYield, type=c("p", "a"), data=cornYield, type=c("p", "a"),
ylab=expression(Yield~(ton~ha^{-1})), ylab=expression(Yield~(ton~ha^{-1})),
xlab="Nutrient level") xlab="Nutrient level")
xyplot(yield~N, groups=interaction(P, K), xyplot(yield~N, groups=interaction(P, K),
data=kornYield, type=c("p", "a"), data=cornYield, type=c("p", "a"),
auto.key=list(columns=2), auto.key=list(columns=2),
ylab=expression(Yield~(ton~ha^{-1})), ylab=expression(Yield~(ton~ha^{-1})),
xlab="Nutrient level") 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} \keyword{datasets}
% 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{kornYield2} \name{cornYield2}
\alias{kornYield2} \alias{cornYield2}
\title{Axial factorial NPK experiment with added treatments} \title{Axial factorial NPK experiment with added treatments}
\format{a \code{data.frame} with 9 records and 5 variables.} \format{a \code{data.frame} with 9 records and 5 variables.}
\source{ \source{
...@@ -17,7 +17,7 @@ data(sugarcaneYield4) ...@@ -17,7 +17,7 @@ data(sugarcaneYield4)
} }
\description{ \description{
These data are from an axial 3 factorial experiment These data are from an axial 3 factorial experiment
studing NPK in the yield of korn. Tow controls were added, one is studing NPK in the yield of corn. Tow controls were added, one is
zer control (no NPK) and the other is central factorial point zer control (no NPK) and the other is central factorial point
plus presence of limestone. plus presence of limestone.
...@@ -26,7 +26,7 @@ These data are from an axial 3 factorial experiment ...@@ -26,7 +26,7 @@ These data are from an axial 3 factorial experiment
\item \code{P} content of phosphorus in the fertilizer. \item \code{P} content of phosphorus in the fertilizer.
\item \code{K} content of potassium in the fertilizer. \item \code{K} content of potassium in the fertilizer.
\item \code{limestone} presence (1) or absence of limestone (0). \item \code{limestone} presence (1) or absence of limestone (0).
\item \code{acid} mean of korn yield in 16 locations (ton/ha). \item \code{acid} mean of corn yield in 16 locations (ton/ha).
} }
} }
\details{ \details{
...@@ -38,15 +38,15 @@ The experiment was caried out in 16 different locations but ...@@ -38,15 +38,15 @@ The experiment was caried out in 16 different locations but
library(lattice) library(lattice)
library(latticeExtra) library(latticeExtra)
data(kornYield2) data(cornYield2)
str(kornYield2) str(cornYield2)
## Axial triple factorial with 2 controls. ## Axial triple factorial with 2 controls.
ftable(xtabs(~N+P+K, data=kornYield2)) ftable(xtabs(~N+P+K, data=cornYield2))
xyplot(yield~N+P+K, xyplot(yield~N+P+K,
groups=as.integer(limestone==1 | (N+P+K)==0), groups=as.integer(limestone==1 | (N+P+K)==0),
data=kornYield2, type=c("p", "a"), data=cornYield2, type=c("p", "a"),
auto.key=TRUE, auto.key=TRUE,
ylab=expression(Yield~(ton~ha^{-1})), ylab=expression(Yield~(ton~ha^{-1})),
xlab="Nutrient content") xlab="Nutrient content")
......
...@@ -40,23 +40,6 @@ xyplot(y~cake, groups=mineral, ...@@ -40,23 +40,6 @@ xyplot(y~cake, groups=mineral,
data=filterCake, type=c("p", "a"), data=filterCake, type=c("p", "a"),
ylab="y", ylab="y",
xlab="Filter cake level") xlab="Filter cake level")
m0 <- lm(y~block+(cake+mineral)^2, data=filterCake)
par(mfrow=c(2,2)); plot(m0); layout(1)
anova(m0)
summary(m0)
filterCake$Mineral <- factor(filterCake$mineral,
labels=c("absent", "present"))
m1 <- aov(y~block+Mineral/cake, data=filterCake)
anova(m1)
## Split SS to see effect of cake in each level of mineral.
summary(m1, split=list("Mineral:cake"=list("absent"=1, "present"=2)))
summary.lm(m1)
} }
\keyword{datasets} \keyword{datasets}
...@@ -20,10 +20,11 @@ None is returned by the function. ...@@ -20,10 +20,11 @@ None is returned by the function.
} }
\description{ \description{
This function opens an interface to control the This function opens an interface to control the
polynomial degree in linear regression. It shows the observed values polynomial degree in linear regression. It shows the observed
and the corresponding fitted curve superimposed with confidence bands values and the corresponding fitted curve superimposed with
(for the fitted values) and also show the residuals plot. It assumes confidence bands (for the fitted values) and also show the
that \code{gWidgets} and \code{gWidgetstcltk} packages are available. residuals plot. It assumes that \code{gWidgets} and
\code{gWidgetstcltk} packages are available.
} }
\examples{ \examples{
\donttest{ \donttest{
......
...@@ -32,7 +32,6 @@ There is a missprint in the book for the 9th entry, which ...@@ -32,7 +32,6 @@ There is a missprint in the book for the 9th entry, which
\examples{ \examples{
library(lattice) library(lattice)
library(latticeExtra) library(latticeExtra)
library(multcomp)
data(sugarcaneYield4) data(sugarcaneYield4)
str(sugarcaneYield4) str(sugarcaneYield4)
...@@ -44,55 +43,6 @@ xyplot(yield~N|P, groups=K, ...@@ -44,55 +43,6 @@ xyplot(yield~N|P, groups=K,
data=sugarcaneYield4, type=c("p", "a"), data=sugarcaneYield4, type=c("p", "a"),
ylab=expression(Yield~(ton~ha^{-1})), ylab=expression(Yield~(ton~ha^{-1})),
xlab="Nitrogen level level") xlab="Nitrogen level level")
## Sums in each cell combination.
addmargins(with(sugarcaneYield4, tapply(yield, list(P, N), FUN=sum)))
addmargins(with(sugarcaneYield4, tapply(yield, list(K, N), FUN=sum)))
addmargins(with(sugarcaneYield4, tapply(yield, list(K, P), FUN=sum)))
sugarcaneYield4 <- transform(sugarcaneYield4,
blockr=interaction(block, rept),
nitro=factor(N),
phosp=factor(P),
potas=factor(K))
str(sugarcaneYield4)
m0 <- lm(yield~blockr+(nitro+phosp+potas)^3, data=sugarcaneYield4)
par(mfrow=c(2,2)); plot(m0); layout(1)
anova(m0)
m1 <- update(m0, .~blockr+(nitro+phosp)^2)
par(mfrow=c(2,2)); plot(m1); layout(1)
anova(m0, m1)
anova(m1)
m2 <- aov(yield~blockr+nitro/phosp, data=sugarcaneYield4)
anova(m2)
PinN <- sapply(paste0("nitro", levels(sugarcaneYield4$nitro)),
FUN=grep, x=names(coef(m2))[m2$assign==3L],
simplify=FALSE)
summary(m2, split=list("nitro:phosp"=PinN))
X <- model.matrix(m1)
X
aggregate(X~nitro+phosp, data=sugarcaneYield4, FUN=mean)
## It is better use multcomp::LSmatrix().
L <- aggregate(X~nitro+phosp, data=sugarcaneYield4, FUN=mean)
rownames(L) <- with(L, paste0("N", nitro, ":P", phosp))
L <- as.matrix(L[, colnames(X)])
str(L)
## Least squares means for N:P combinations.
L\%*\%coef(m1)
g1 <- glht(m1, linfct=L)
confint(g1, calpha=univariate_calpha())
} }
\keyword{datasets} \keyword{datasets}
...@@ -40,18 +40,6 @@ xyplot(y~vinasse, groups=mineral, ...@@ -40,18 +40,6 @@ xyplot(y~vinasse, groups=mineral,
data=vinasseFert, type=c("p", "a"), data=vinasseFert, type=c("p", "a"),
ylab="y", ylab="y",
xlab="Vinasse level") 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} \keyword{datasets}
% 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{wgpigs} \name{wgPigs}
\alias{wgpigs} \alias{wgPigs}
\title{Feeding type in pig weight gain} \title{Feeding type in pig weight gain}
\format{a \code{data.frame} with 20 records and 2 variables.} \format{a \code{data.frame} with 20 records and 2 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 62) ed.). Piracicaba, São Paulo: FEALQ. (page 62)
} }
\usage{ \usage{
data(wgpigs) data(wgPigs)
} }
\description{ \description{
This is an artifial dataset corresponding a experiment This is an artifial dataset corresponding a experiment
...@@ -29,9 +29,9 @@ This is an artifial dataset corresponding a experiment ...@@ -29,9 +29,9 @@ This is an artifial dataset corresponding a experiment
} }
\examples{ \examples{
library(lattice) library(lattice)
data(wgpigs) data(wgPigs)
xyplot(wg~ft, data=wgpigs, xyplot(wg~ft, data=wgPigs,
ylab="Weight gain (kg)", ylab="Weight gain (kg)",
xlab="Feeding type") xlab="Feeding type")
} }
......
% 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{wgpigs2} \name{wgPigs2}
\alias{wgpigs2} \alias{wgPigs2}
\title{Age of castration in pig weight gain} \title{Age of castration in pig weight gain}
\format{a \code{data.frame} with 16 records and 4 variables.} \format{a \code{data.frame} with 16 records and 4 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 110) ed.). Piracicaba, São Paulo: FEALQ. (page 110)
} }
\usage{ \usage{
data(wgpigs2) data(wgPigs2)
} }
\description{ \description{
This is an artifial dataset corresponding a experiment This is an artifial dataset corresponding a experiment
...@@ -36,41 +36,12 @@ This is an artifial dataset corresponding a experiment ...@@ -36,41 +36,12 @@ This is an artifial dataset corresponding a experiment
\examples{ \examples{
library(lattice) library(lattice)
data(wgpigs2) data(wgPigs2)
str(wgpigs2) str(wgPigs2)
xyplot(wg~age, data=wgpigs2, groups=litter, xyplot(wg~age, data=wgPigs2, groups=litter,
ylab="Weight gain (kg)", ylab="Weight gain (kg)",
xlab="Age at castration (days)") xlab="Age at castration (days)")
m0 <- lm(wg~litter+size+age, data=wgpigs2)
par(mfrow=c(2,2)); plot(m0); layout(1)
anova(m0)
summary(m0)
library(multcomp)
summary(glht(m0, linfct=mcp(age="Dunnet")),
test=adjusted(type="single-step"))
m1 <- glm(wg~litter+size+age, data=wgpigs2, family=Gamma)
m2 <- glm(wg~litter+size+age, data=wgpigs2,
family=Gamma(link="log"))
m3 <- glm(wg~litter+size+age, data=wgpigs2,
family=Gamma(link="identity"))
rbind(logLik(m0),
logLik(m1),
logLik(m2),
logLik(m3))
par(mfrow=c(2,2)); plot(m1); layout(1)
anova(m1, test="F")
anova(m2, test="F")
anova(m3, test="F")
summary(glht(m3, linfct=mcp(age="Dunnet")),
test=adjusted(type="single-step"))
} }
\keyword{datasets} \keyword{datasets}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment