diff --git a/buildPkg.R b/buildPkg.R index 8f1fe872da710dd750791d288955a1cfb8c0673a..1de46c327a17bf7c56f9555c672821753b447e1e 100644 --- a/buildPkg.R +++ b/buildPkg.R @@ -41,10 +41,25 @@ build(manual = TRUE, vignettes = FALSE) # build the binary version for windows (not used) # build_win() +##---------------------------------------------------------------------- +## Test installation. + ## Test install with install.packages pkg <- paste0("../legTools_", packageVersion("legTools"), ".tar.gz") 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 ## downloadable diff --git a/man/cornYield.Rd b/man/cornYield.Rd new file mode 100644 index 0000000000000000000000000000000000000000..7c7d0580367cb88c9d9e49a22fac3b7036e31580 --- /dev/null +++ b/man/cornYield.Rd @@ -0,0 +1,47 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/legTools.R +\docType{data} +\name{cornYield} +\alias{cornYield} +\title{Corn 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(cornYield) +} +\description{ +These data are from an \eqn{2^3} factorial experiment + studing the effect of Nitrogen (N), Phosporus (P) and Potassium + (K) on corn 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} corn yield (ton/ha). +} +} +\examples{ +library(lattice) +library(latticeExtra) + +data(cornYield) +str(cornYield) + +xyplot(yield~N|P, groups=K, + data=cornYield, type=c("p", "a"), + ylab=expression(Yield~(ton~ha^{-1})), + xlab="Nutrient level") + +xyplot(yield~N, groups=interaction(P, K), + data=cornYield, type=c("p", "a"), + auto.key=list(columns=2), + ylab=expression(Yield~(ton~ha^{-1})), + xlab="Nutrient level") +} +\keyword{datasets} + diff --git a/man/kornYield2.Rd b/man/cornYield2.Rd similarity index 83% rename from man/kornYield2.Rd rename to man/cornYield2.Rd index e016f44e725fdbe6401e214508365d3266e2a842..e6f18b139b10b52eb16a3583cb58d9c023e62644 100644 --- a/man/kornYield2.Rd +++ b/man/cornYield2.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/legTools.R \docType{data} -\name{kornYield2} -\alias{kornYield2} +\name{cornYield2} +\alias{cornYield2} \title{Axial factorial NPK experiment with added treatments} \format{a \code{data.frame} with 9 records and 5 variables.} \source{ @@ -17,7 +17,7 @@ data(sugarcaneYield4) } \description{ 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 plus presence of limestone. @@ -26,7 +26,7 @@ These data are from an axial 3 factorial experiment \item \code{P} content of phosphorus in the fertilizer. \item \code{K} content of potassium in the fertilizer. \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{ @@ -38,15 +38,15 @@ The experiment was caried out in 16 different locations but library(lattice) library(latticeExtra) -data(kornYield2) -str(kornYield2) +data(cornYield2) +str(cornYield2) ## 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, groups=as.integer(limestone==1 | (N+P+K)==0), - data=kornYield2, type=c("p", "a"), + data=cornYield2, type=c("p", "a"), auto.key=TRUE, ylab=expression(Yield~(ton~ha^{-1})), xlab="Nutrient content") diff --git a/man/filterCake.Rd b/man/filterCake.Rd index 2f65788c77d2c9d04d3f8ab34ae9bdb45b4b9091..6ddae712d3635d514921f43d8296b20c26f83a62 100644 --- a/man/filterCake.Rd +++ b/man/filterCake.Rd @@ -40,23 +40,6 @@ xyplot(y~cake, groups=mineral, data=filterCake, type=c("p", "a"), ylab="y", 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} diff --git a/man/kornYield.Rd b/man/kornYield.Rd deleted file mode 100644 index be35646c7d45321f0319e8f3ad3301126e51277a..0000000000000000000000000000000000000000 --- a/man/kornYield.Rd +++ /dev/null @@ -1,76 +0,0 @@ -% 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} - diff --git a/man/loessGui.Rd b/man/loessGui.Rd index 6c5ad1404e9efeed995a7de4eb7c4a52d76d0162..c2901e7a5d4e5320895527583114842648b106b3 100644 --- a/man/loessGui.Rd +++ b/man/loessGui.Rd @@ -12,8 +12,8 @@ loessGui(x, y, data, er = 0.05) \item{data}{an optional \code{data.frame}.} \item{er}{stands for extend range. It is used to extend the plotting -range by a fraction on both sides and directions. Default is -0.05. See \link[grDevices]{extendrange}.} + range by a fraction on both sides and directions. Default is + 0.05. See \link[grDevices]{extendrange}.} } \value{ None is returned by the function, only a GUI is opened. @@ -22,11 +22,11 @@ None is returned by the function, only a GUI is opened. This function opens an interface to control the settings of a loess regression: \itemize{ - \item degree choose the local polynomial degree with a radio + \item degree choose the local polynomial degree with a radio selector; - \item span set the span value that controls the degree of + \item span set the span value that controls the degree of smoothing; - \item center move the x value to be predicted; + \item center move the x value to be predicted; } The elements of the interface change a plot that shows the observed diff --git a/man/polyGui.Rd b/man/polyGui.Rd index 4b084c8f62269e04cc3dc5a0b1fdb6509a62f177..049c113c519ccc5f715232f86ae97fc5d1c72377 100644 --- a/man/polyGui.Rd +++ b/man/polyGui.Rd @@ -12,18 +12,19 @@ polyGui(x, y, data, er = 0.05) \item{data}{an optional \code{data.frame}.} \item{er}{stands for extend range. It is used to extend the plotting -range by a fraction on both sides and directions. Default is -0.05. See \link[grDevices]{extendrange}.} + range by a fraction on both sides and directions. Default is + 0.05. See \link[grDevices]{extendrange}.} } \value{ None is returned by the function. } \description{ This function opens an interface to control the -polynomial degree in linear regression. It shows the observed values -and the corresponding fitted curve superimposed with confidence bands -(for the fitted values) and also show the residuals plot. It assumes -that \code{gWidgets} and \code{gWidgetstcltk} packages are available. + polynomial degree in linear regression. It shows the observed + values and the corresponding fitted curve superimposed with + confidence bands (for the fitted values) and also show the + residuals plot. It assumes that \code{gWidgets} and + \code{gWidgetstcltk} packages are available. } \examples{ \donttest{ diff --git a/man/runAllChunks.Rd b/man/runAllChunks.Rd index 3602646e0ca20153358dd7f3bf75304c4902a54f..e8abbbe62431f8cd6e91f81ca19224c8c065bfc8 100644 --- a/man/runAllChunks.Rd +++ b/man/runAllChunks.Rd @@ -10,15 +10,15 @@ runAllChunks(Rmd, envir = globalenv()) \item{Rmd}{the name of the Rmd file.} \item{envir}{the environment in which the chunks will be -evaluated. By default it is the GlobalEnv.} + evaluated. By default it is the GlobalEnv.} } \value{ Objects created in the chunks from the Rmd file. } \description{ This function was developed to run all chunks in a knitr -Rmd (R markdown) file at once. Mainly for exploring and debugging -purposes. + Rmd (R markdown) file at once. Mainly for exploring and debugging + purposes. } \author{ Fernando Mayer, \email{fernando.mayer@ufpr.br} diff --git a/man/sugarcaneYield4.Rd b/man/sugarcaneYield4.Rd index 4095578ff1bb766bf613b934cc5d768cfc137b74..b0a20021e4e7cf9284dde5a41e0adf2d7dd855d4 100644 --- a/man/sugarcaneYield4.Rd +++ b/man/sugarcaneYield4.Rd @@ -32,7 +32,6 @@ There is a missprint in the book for the 9th entry, which \examples{ library(lattice) library(latticeExtra) -library(multcomp) data(sugarcaneYield4) str(sugarcaneYield4) @@ -44,55 +43,6 @@ xyplot(yield~N|P, groups=K, data=sugarcaneYield4, type=c("p", "a"), ylab=expression(Yield~(ton~ha^{-1})), 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} diff --git a/man/vinasseFert.Rd b/man/vinasseFert.Rd index ae7a36622fcba75164cfb7d5df6ce2912864b1a1..c52ece6e40284557829e798b3e7279cf95c6783a 100644 --- a/man/vinasseFert.Rd +++ b/man/vinasseFert.Rd @@ -40,18 +40,6 @@ xyplot(y~vinasse, groups=mineral, 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} diff --git a/man/wgpigs.Rd b/man/wgPigs.Rd similarity index 92% rename from man/wgpigs.Rd rename to man/wgPigs.Rd index 3fc9a3ee41e441766520f2385b24fb0e11bb5095..e107692f914c6ec870518286efbb857f8a2c4e78 100644 --- a/man/wgpigs.Rd +++ b/man/wgPigs.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/legTools.R \docType{data} -\name{wgpigs} -\alias{wgpigs} +\name{wgPigs} +\alias{wgPigs} \title{Feeding type in pig weight gain} \format{a \code{data.frame} with 20 records and 2 variables.} \source{ @@ -10,7 +10,7 @@ Frederico, P. (2009). Curso de Estatística Experimental (15th ed.). Piracicaba, São Paulo: FEALQ. (page 62) } \usage{ -data(wgpigs) +data(wgPigs) } \description{ This is an artifial dataset corresponding a experiment @@ -29,9 +29,9 @@ This is an artifial dataset corresponding a experiment } \examples{ library(lattice) -data(wgpigs) +data(wgPigs) -xyplot(wg~ft, data=wgpigs, +xyplot(wg~ft, data=wgPigs, ylab="Weight gain (kg)", xlab="Feeding type") } diff --git a/man/wgpigs2.Rd b/man/wgPigs2.Rd similarity index 63% rename from man/wgpigs2.Rd rename to man/wgPigs2.Rd index ef1ff362972e3819e5729ee033364a79120d4cb4..8ac1bb48b2aae8dae99418fa7113c493a9e978b3 100644 --- a/man/wgpigs2.Rd +++ b/man/wgPigs2.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/legTools.R \docType{data} -\name{wgpigs2} -\alias{wgpigs2} +\name{wgPigs2} +\alias{wgPigs2} \title{Age of castration in pig weight gain} \format{a \code{data.frame} with 16 records and 4 variables.} \source{ @@ -10,7 +10,7 @@ Frederico, P. (2009). Curso de Estatística Experimental (15th ed.). Piracicaba, São Paulo: FEALQ. (page 110) } \usage{ -data(wgpigs2) +data(wgPigs2) } \description{ This is an artifial dataset corresponding a experiment @@ -36,41 +36,12 @@ This is an artifial dataset corresponding a experiment \examples{ library(lattice) -data(wgpigs2) -str(wgpigs2) +data(wgPigs2) +str(wgPigs2) -xyplot(wg~age, data=wgpigs2, groups=litter, +xyplot(wg~age, data=wgPigs2, groups=litter, ylab="Weight gain (kg)", 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}