Skip to content

Commit

Permalink
version 1.0-7
Browse files Browse the repository at this point in the history
  • Loading branch information
Felipe de Mendiburu authored and gaborcsardi committed Apr 20, 2009
1 parent 4be5a3c commit 8e18d15
Show file tree
Hide file tree
Showing 16 changed files with 283 additions and 40 deletions.
38 changes: 26 additions & 12 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
Package: agricolae
Type: Package
Title: Statistical Procedures for Agricultural Research
Version: 1.0-6
Date: 2008-12-17
Author: Felipe de Mendiburu
Maintainer: Felipe de Mendiburu <f.mendiburu@cgiar.org>
Suggests: akima, klaR, SuppDists, corpcor
Description: Agricolae is a project in order to obtain the degree of master in Systems Engineering in the National University of Engineering in Lima-Peru (UNI in Spanish). These functions are currently utilized by the International Potato Center Research (CIP), the Universidad Nacional Agraria La Molina (UNALM-PERU), and the Instituto Nacional de Investigacion Agricola (INIA-PERU). It comprises the functionality of statistical analysis into experimental designs applied specially for field experiments in agriculture and plant breeding: Lattice, factorial, complete and incomplete block, Latin Square, Greaco, Alpha designs, Cyclic designs, comparison of multi-location trials, comparison between treatments, resampling, simulation, biodiversity indexes and consensus cluster.
License: GPL
URL: http://tarwi.lamolina.edu.pe/~fmendiburu
Packaged: Wed Dec 17 09:47:13 2008; fdemendiburu
Package: agricolae
Type: Package
Title: Statistical Procedures for Agricultural Research
Version: 1.0-7
Date: 2009-4-20
Author: Felipe de Mendiburu
Maintainer: Felipe de Mendiburu <f.mendiburu@cgiar.org>
Suggests: akima, klaR, SuppDists, corpcor
Description: Agricolae is a project in order to obtain the degree of
master in Systems Engineering in the National University of
Engineering in Lima-Peru (UNI in Spanish). These functions are
currently utilized by the International Potato Center Research
(CIP), the Universidad Nacional Agraria La Molina (UNALM-PERU),
and the Instituto Nacional de Investigacion Agricola
(INIA-PERU). It comprises the functionality of statistical
analysis into experimental designs applied specially for field
experiments in agriculture and plant breeding: Lattice,
factorial, complete and incomplete block, Latin Square, Greaco,
Alpha designs, Cyclic designs, comparison of multi-location
trials, comparison between treatments, resampling, simulation,
biodiversity indexes and consensus cluster.
License: GPL
URL: http://tarwi.lamolina.edu.pe/~fmendiburu
Packaged: 2009-04-20 13:52:25 UTC; fdemendiburu
Repository: CRAN
Date/Publication: 2009-04-20 17:21:12
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exportPattern("^[[:alpha:]]+")
S3method(summary,graph.freq)
S3method(plot,graph.freq)
4 changes: 2 additions & 2 deletions R/graph.freq.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ a<-breaks[1]-ancho[1]/2
b<-breaks[k+1]+ancho[k]/2
relative<-round(counts/sum(counts),4)
density <- relative/ancho
histogram<-list(breaks=breaks,counts=counts,mids=mids,relative=relative,density=density)
histogram<-structure(list(breaks=breaks,counts=counts,mids=mids,relative=relative,density=density),class="graph.freq")

if(plot) {
x <- c(a, b)
Expand All @@ -90,5 +90,5 @@ for (j in 1:k) {
suppressWarnings(warning(rect(breaks[j], 0, breaks[j + 1], density[j], ...)))
}}
}
return(histogram)
invisible(histogram)
}
95 changes: 95 additions & 0 deletions R/plot.graph.freq.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
`plot.graph.freq` <-
function (x, breaks="sturges",counts=NULL,frequency=1, plot=TRUE, nclass=NULL,xlab="",ylab="",...)
{
if (xlab=="") xlab= deparse(substitute(x))
if (is.numeric(x) & is.null(counts)) {
# histogram
if (is.null(nclass)) {
if (length(breaks)==1) {
x<-na.omit(x)
if(breaks== "sturges") breaks <- sturges.freq(x)$breaks
}
}
else {
amplitud <- max(x)-min(x)
n <- length(x)
z<-rep(0,n)
y<- as.character(x)
for (i in 1:n) {
lc<-nchar(y[i])
nd<-0
for (j in 1:lc) {
a <- substr(y[i],j,j)
if(a!=".")nd=nd+1
else break
}
z[i]<- lc-nd-1
}
d<-max(z)
if(d<0) d=0
tic <- round(amplitud/nclass + 0.5 * 10^(-d), d)
breaks <-seq(min(x), by=tic, length=nclass+1)
}

k<-length(breaks)
n<- length(x)
counts <- rep(0,k-1)
for (i in 1:n) {
for (j in 1:(k-1)) {
if( (x[i] >= breaks[j]) && (x[i] < breaks[j + 1])) counts[j]<-counts[j]+1
}
}
k <- length(counts)
mids <- rep(0, k)
ancho <- rep(0, k)
for (i in 1:k) {
mids[i] <- (breaks[i] + breaks[i + 1])/2
ancho[i] <- (breaks[i + 1] - breaks[i])
}
altura <- round(1.1 * max(counts), 0)
}
#############
else {
if( is.list(x)) {
breaks<- x$breaks
counts <- x$counts
}
else breaks <- x
k<-length(counts)
mids<-rep(0,k)
ancho<-rep(0,k)
for (i in 1:k) {
mids[i]<-(breaks[i]+breaks[i+1])/2
ancho[i]<-(breaks[i+1]-breaks[i])
}
}
################
a<-breaks[1]-ancho[1]/2
b<-breaks[k+1]+ancho[k]/2
relative<-round(counts/sum(counts),4)
density <- relative/ancho
histogram<-list(breaks=breaks,counts=counts,mids=mids,relative=relative,density=density)

if(plot) {
x <- c(a, b)
if(frequency==1)height<-round(1.1*max(counts),1)
if(frequency==2)height<-round(1.1*max(relative),4)
if(frequency==3)height<-round(1.1*max(density),4)
y <- c(0, height)
suppressWarnings(warning(plot(x,y, type = "n", xlab=xlab,ylab=ylab,...)))
if (frequency==1) {
for (j in 1:k) {
suppressWarnings(warning(rect(breaks[j], 0, breaks[j + 1], counts[j], ...)))
}}
if (frequency==2) {
for (j in 1:k) {
suppressWarnings(warning(rect(breaks[j], 0, breaks[j + 1], relative[j], ...)))
}}
if (frequency==3) {
for (j in 1:k) {
suppressWarnings(warning(rect(breaks[j], 0, breaks[j + 1], density[j], ...)))
}}
}
invisible(histogram)
}

25 changes: 25 additions & 0 deletions R/summary.graph.freq.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
`summary.graph.freq` <-
function(object,...){
xx<-object$mids
yy<-object$counts
y1<-sum(yy)
zz<-object$breaks
x<-length(xx)
acum<-0
z<-rep(0,7*x)
dim(z)<-c(x,7)
for (i in 1:x) {
z[i,1]<-zz[i]
z[i,2]<-zz[i+1]
z[i,3]<-xx[i]
z[i,4]<-yy[i]
z[i,5]<-yy[i]/y1
z[i,6]<-yy[i]+acum
acum<-z[i,6]
z[i,7]<-z[i,6]/y1
}
colnames(z)<-c("Inf","Sup","MC","fi","fri","Fi","Fri")
rownames(z)<-rep(" ",x)
return(z)
}

8 changes: 4 additions & 4 deletions R/table.freq.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
`table.freq` <-
function(histogram){
xx<-histogram$mids
yy<-histogram$counts
function(object){
xx<-object$mids
yy<-object$counts
y1<-sum(yy)
zz<-histogram$breaks
zz<-object$breaks
x<-length(xx)
acum<-0
z<-rep(0,7*x)
Expand Down
4 changes: 2 additions & 2 deletions man/agricolae.package.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ designs applied specially for field experiments in agriculture and plant breedin
\tabular{ll}{
Package: \tab agricolae\cr
Type: \tab Package\cr
Version: \tab 1.0-6\cr
Date: \tab 2008-12-17\cr
Version: \tab 1.0-7\cr
Date: \tab 2009-04-20\cr
License: \tab GPL\cr
}
Planning of field experiments: lattice, factorial, RCBD, CRD, Latin Square, Graeco, BIB, Alpha design, Cyclic Designs.
Expand Down
2 changes: 1 addition & 1 deletion man/cv.model.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cv.model(x)
\item{x}{ object of model lm() or AOV() }
}
\details{
$\frac{sqrt(MSerror)}{mean(x)}\*100$
sqrt(MSerror)*100/mean(x)
}
\value{

Expand Down
2 changes: 1 addition & 1 deletion man/design.bib.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ library(agricolae)
# 4 treatments and k=3 size block
trt<-c("A","B","C","D")
k<-3
bib <-design.bib(trt,k,number=101,seed =41,kinds ="Super-Duper") # seed = 37
bib <-design.bib(trt,k,number=101,seed =41,kinds ="Super-Duper") # seed = 41
plots <-as.numeric(bib[,1])
field <-as.character(bib[,3])
t(matrix(plots,c(3,4)))
Expand Down
4 changes: 3 additions & 1 deletion man/index.bio.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ index.bio(data, method = c("Margalef", "Simpson.Dom", "Simpson.Div", "Berger.Par
\item{level }{ value 0-100 percentage }
\item{nboot }{ size 100, 500,... }
}
\references{Efron, B., Tibshirani, R. (1993) An Introduction to the Boostrap. Chapman and Hall/CRC }
\references{Magurran, A.E. (1988) Ecological diversity and its measurement. Princeton University Press
Efron, B., Tibshirani, R. (1993) An Introduction to the Boostrap. Chapman and Hall/CRC
}
\author{ Felipe de Mendiburu }
\examples{
library(agricolae)
Expand Down
2 changes: 1 addition & 1 deletion man/index.smith.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ index.smith(data, ...)
}
\details{

$V_{x}=\frac{V_{(x)}}{x^b}$
Vx=V(x)/x b


V(x) is the between-plot variance,
Expand Down
6 changes: 0 additions & 6 deletions man/kurtosis.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ kurtosis(x)
\arguments{
\item{x}{ a numeric vector }
}
\details{

n = length(x)

$\frac{n(n+1)}{(n-1)(n-2)(n-3)}\sum_{i}\left(\frac{x_i - mean(x)}{sd(x)}\right)^4 - \frac{3(n-1)^2}{(n-2)(n-3)}$

}
\value{

\item{x }{ The kurtosis of x }
Expand Down
85 changes: 85 additions & 0 deletions man/plot.graph.freq.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
\name{plot.graph.freq}
\alias{plot.graph.freq}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{ Histogram }
\description{
In many situations it has intervals of class defined with its respective
frequencies. By means of this function, the graphic of frequency is obtained
and it is possible to superpose the normal distribution, polygon of frequency,
Ojiva and to construct the table of complete frequency.
}
\usage{
plot.graph.freq(x, breaks="sturges",counts=NULL,frequency=1, plot=TRUE, nclass=NULL,xlab="",ylab="",...)

}
\arguments{
\item{x}{ a vector of values, a object hist(), graph.freq() }
\item{counts}{ frequency and x is class intervals}
\item{breaks}{ a vector giving the breakpoints between histogram cells }
\item{frequency}{ 1=counts, 2=relative, 3=density }
\item{plot}{ logic }
\item{nclass}{ number of classes }
\item{xlab}{ x labels}
\item{ylab}{ y labels}
\item{\dots}{ other parameters of graphic}
}

\value{
\item{x }{Numeric or list}
\item{plot }{TRUE or FALSE}
\item{counts }{Numeric}
\item{frequency}{ Numeric }

}

\author{ Felipe de Mendiburu }

\seealso{\code{\link{polygon.freq}}, \code{\link{table.freq}}, \code{\link{stat.freq}},
\code{\link{intervals.freq}}, \code{\link{sturges.freq}}, \code{\link{join.freq}},
\code{\link{ojiva.freq}}, \code{\link{normal.freq} } }

\examples{

library(agricolae)
data(genxenv)
yield <- subset(genxenv$YLD,genxenv$ENV==2)
yield <- round(yield,1)
h<- graph.freq(yield,axes=FALSE, frequency=1, ylab="frequency",col="yellow")
axis(1,h$breaks)
axis(2,seq(0,20,0.1))
# To reproduce histogram.
h1 <- graph.freq(h, col="blue", frequency=2,border="red", density=8,axes=FALSE, xlab="YIELD",ylab="relative")
axis(1,h$breaks)
axis(2,seq(0,.4,0.1))
# summary, only frecuency
limits <-seq(10,40,5)
frequencies <-c(2,6,8,7,3,4)
#startgraph
h<-graph.freq(limits,counts=frequencies,col="bisque",xlab="Classes")
polygon.freq(h,col="red")
title( main="Histogram and polygon of frequency",
ylab="Frequency")
#endgraph
# Statistics
measures<-stat.freq(h)
print(measures)
# frequency table full
round(table.freq(h),2)
#startgraph
# Ojiva
ojiva.freq(h,col="red",type="b",xlab="Variable",ylab="Accumulated relative frequency")
# only frequency polygon
h<-graph.freq(limits,counts=frequencies,border=FALSE,col=NULL,xlab=" ",ylab="")
title( main="Polygon of frequency",
xlab="Variable", ylab="Frecuency")
polygon.freq(h,col="blue")
grid(col="brown")
#endgraph
# Draw curve for Histogram
h<- graph.freq(yield,axes=FALSE, frequency=3, ylab="f(yield)",col="yellow")
axis(1,h$breaks)
axis(2,seq(0,0.18,0.03),las=2)
lines(density(yield), col = "red", lwd = 2)
title("Draw curve for Histogram")
}
\keyword{ aplot }% at least one, from doc/KEYWORDS
6 changes: 0 additions & 6 deletions man/skewness.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ skewness(x)
\arguments{
\item{x}{a numeric vector}
}
\details{

n = length(x)

$\frac{n}{(n-1)(n-2)}\sum_{i}\left(\frac{x_i - mean(x)}{sd(x)}\right)^3$

}
\value{

\item{x }{The skewness of x}
Expand Down
31 changes: 31 additions & 0 deletions man/summary.graph.freq.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
\name{summary.graph.freq}
\alias{summary.graph.freq}
\title{ Frequency Table of a Histogram }
\description{
It finds the absolute, relative and accumulated frequencies with the class
intervals defined from a previously calculated histogram by "graph.freq".
}
\usage{
summary.graph.freq(object,...)
}

\arguments{
\item{object}{Object by function graph.freq() }
\item{\dots}{ other parameters of graphic}
}
\value{
\item{object }{Object by graph.freq()}
}
\author{ Felipe de Mendiburu }

\seealso{\code{\link{polygon.freq}}, \code{\link{stat.freq}}, \code{\link{graph.freq}},
\code{\link{intervals.freq}}, \code{\link{sturges.freq}}, \code{\link{join.freq}},
\code{\link{ojiva.freq}}, \code{\link{normal.freq} } }
\examples{
library(agricolae)
data(growth)
attach(growth)
h2<-graph.freq(height,plot=FALSE)
summary(h2)
}
\keyword{ distribution }% at least one, from doc/KEYWORDS
Loading

0 comments on commit 8e18d15

Please sign in to comment.