Skip to content

Commit

Permalink
nv
Browse files Browse the repository at this point in the history
  • Loading branch information
igorcobelo committed Jun 26, 2020
1 parent ba8f54e commit efee0aa
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 87 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Version: 0.1.0
Author: Igor Cobelo Ferreira
Maintainer: Igor Cobelo Ferreira <[email protected]>
Description: The functions return the volumetric and phytosociological sampling parameters for forest inventories.
License: GPL-3.0
License: GPL(>=3)
Encoding: UTF-8
LazyData: TRUE
Citation: https://github.com/igorcobelo/forestry/blob/master/inst/citation
Depends:
R(>= 3.5.0),
Depends: R(>= 3.5.0)
Imports:
BiodiversityR,
cowplot,
data.table,
Expand Down
8 changes: 3 additions & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Generated by roxygen2: do not edit by hand

export(fito)
export(indvol)
export(acs)
export(ace)
export(bit)
export(fito,indvol,ace,acs,bit)
importFrom('BiodiversityR', 'cowplot', 'data.table', 'dplyr', 'flextable', 'ggplot2',
'officer', 'rvg', 'tidyr', 'tidyverse')
156 changes: 80 additions & 76 deletions R/indvol.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ indvol <- function(x, mens="plot", vol=F, myeq=NULL, veg=NULL, f=NULL, circ=F) {
plan<-data.frame(p,row,s,h,d,volume, stringsAsFactors = F)

}else{
plan<-data.frame(p,row,s,h,d, stringsAsFactors = F)
plan<-data.frame(p,row,s,h,d, stringsAsFactors = F)
}

}
Expand Down Expand Up @@ -147,7 +147,7 @@ indvol <- function(x, mens="plot", vol=F, myeq=NULL, veg=NULL, f=NULL, circ=F) {
plan<-data.frame(e,p,row,s,h,d,volume, stringsAsFactors = F)

}else{
plan<-data.frame(e,p,row,s,h,d, stringsAsFactors = F)
plan<-data.frame(e,p,row,s,h,d, stringsAsFactors = F)
}
}

Expand Down Expand Up @@ -185,7 +185,7 @@ indvol <- function(x, mens="plot", vol=F, myeq=NULL, veg=NULL, f=NULL, circ=F) {
h<- as.numeric(result2[!(result2==-Inf)])
row<- as.numeric(rownames(result2)[!(result2==-Inf)])


#ESPECIES
x[,2]<-as.character(x[,2])

Expand All @@ -200,18 +200,18 @@ indvol <- function(x, mens="plot", vol=F, myeq=NULL, veg=NULL, f=NULL, circ=F) {
#VOLUME
if(vol==T){

resultvol<-as.numeric()
for(i in x[,1]){
resultvol[i]<-sum(subset(x[,5], x[,1]==i))
}
resultvol<-as.data.frame(resultvol)

volume<- resultvol[!(is.na(resultvol))]

plan<-data.frame(row,s,h,d,volume, stringsAsFactors = F)

resultvol<-as.numeric()
for(i in x[,1]){
resultvol[i]<-sum(subset(x[,5], x[,1]==i))
}
resultvol<-as.data.frame(resultvol)
volume<- resultvol[!(is.na(resultvol))]
plan<-data.frame(row,s,h,d,volume, stringsAsFactors = F)
}else{
plan<-data.frame(row,s,h,d, stringsAsFactors = F)
plan<-data.frame(row,s,h,d, stringsAsFactors = F)
}
}

Expand All @@ -230,75 +230,79 @@ indvol <- function(x, mens="plot", vol=F, myeq=NULL, veg=NULL, f=NULL, circ=F) {
plan<-x
}


if(vol==F){
#Para myeq:

if(!(is.null(myeq))){

plan$`Volume (m3)` <- eval(substitute(myeq), envir=plan); plan
}

#Para fator de forma (hf):

if(!(is.null(f))){
plan$`Volume (m3)`<-(pi*d^2/40000)*h*f
}

#Para veg:
if(!is.null(veg)){

if(veg=="cerrado"){
plan$`Volume (m3)`<-0.000065661*d^(2.475293)* h^(0.300022)
}
if(veg=="cer_regen"){
plan$`Volume (m3)`<-0.000058468*d^(2.160042)* h^(0.791208)
}

if(veg=="campo_cer"){
plan$`Volume (m3)`<-0.000024059*d^(2.506122)* h^(0.929214)
}

if(veg=="cerradao"){
plan$`V (m3)`<-0.000094001*d^(1.830398)* h^(0.960913)
}

if(veg=="mata_pri"){
plan$`Volume (m3)`<-0.00024502*d^(2.265786)* h^(0.150001)
}

if(veg=="mata_sec"){
plan$`Volume (m3)`<-0.000074230*d^(1.707348)* h^(1.16873)
}

if(veg=="mata_ciliar"){
plan$`Volume (m3)`<-0.000065607*d^(2.084676)* h^(0.752177)
}

if(veg=="mata_seca"){
plan$`Volume (m3)`<-0.000074924*d^(1.818557)* h^(1.061157)
}
if(vol==F){
#Para myeq:

if(veg=="trans_cipo"){
plan$`Volume (m3)`<-0.0000065231*d^(1.64498)* h^(2.234673)
if(!(is.null(myeq))){

d<-plan$d
h<-plan$h

plan$`Volume (m3)` <- eval(parse(text = as.character(myeq)))

}

if(veg=="trans_jaiba"){
plan$`Volume (m3)`<-0.000057947*d^(1.911894)* h^(1.0751)
}
#Para fator de forma (hf):

if(veg=="caat_arborea"){
plan$`Volume (m3)`<-0.0000408657*d^(2.235528)* h^(0.823993)
if(!(is.null(f))){
plan$`Volume (m3)`<-(pi*d^2/40000)*h*f
}

if(veg=="caat_arbustiva"){
plan$`Volume (m3)`<-0.000075999*d^(2.016671)* h^(0.761177)
#Para veg:
if(!is.null(veg)){

if(veg=="cerrado"){
plan$`Volume (m3)`<-0.000065661*d^(2.475293)* h^(0.300022)
}
if(veg=="cer_regen"){
plan$`Volume (m3)`<-0.000058468*d^(2.160042)* h^(0.791208)
}

if(veg=="campo_cer"){
plan$`Volume (m3)`<-0.000024059*d^(2.506122)* h^(0.929214)
}

if(veg=="cerradao"){
plan$`V (m3)`<-0.000094001*d^(1.830398)* h^(0.960913)
}

if(veg=="mata_pri"){
plan$`Volume (m3)`<-0.00024502*d^(2.265786)* h^(0.150001)
}

if(veg=="mata_sec"){
plan$`Volume (m3)`<-0.000074230*d^(1.707348)* h^(1.16873)
}

if(veg=="mata_ciliar"){
plan$`Volume (m3)`<-0.000065607*d^(2.084676)* h^(0.752177)
}

if(veg=="mata_seca"){
plan$`Volume (m3)`<-0.000074924*d^(1.818557)* h^(1.061157)
}

if(veg=="trans_cipo"){
plan$`Volume (m3)`<-0.0000065231*d^(1.64498)* h^(2.234673)
}

if(veg=="trans_jaiba"){
plan$`Volume (m3)`<-0.000057947*d^(1.911894)* h^(1.0751)
}

if(veg=="caat_arborea"){
plan$`Volume (m3)`<-0.0000408657*d^(2.235528)* h^(0.823993)
}

if(veg=="caat_arbustiva"){
plan$`Volume (m3)`<-0.000075999*d^(2.016671)* h^(0.761177)
}

}

}

}


colnames(plan)[1]<-colnames(x)[1]
colnames(plan)[2]<-colnames(x)[2]
Expand All @@ -312,7 +316,7 @@ indvol <- function(x, mens="plot", vol=F, myeq=NULL, veg=NULL, f=NULL, circ=F) {
if(mens=="strata"){
colnames(plan)[6]<-colnames(x)[6]
}
return(plan)

}

return(plan)
}
7 changes: 4 additions & 3 deletions man/indvol.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ indvol(x, mens="plot", vol=F, myeq=NULL, veg=NULL, f=NULL, circ=F)
}
\item{vol}{Logical. If already have a volume column (last), vol=T.
}
\item{myeq}{Optional. User can calculate a diferent equation using height (h) and diameter (d), e.g.:
0.000065661*d^(2.475293)* h^(0.300022)}
\item{myeq}{Optional. User can calculate a diferent equation using height (h) and diameter (d), in quotes, e.g.:
"0.000065661*d^(2.475293)*h^(0.300022)"
}
\item{veg}{Optional. A vegetable formation (equations for volume with bark):

- "cerrado" (cerrado/brazilian savannah): 0.000065661*d^(2.475293)* h^(0.300022)
Expand Down Expand Up @@ -95,7 +96,7 @@ head(simple1)

#Using an equation entered manually

IF_simple <- indvol(x = simple1, mens="plot", myeq = 0.000065661*d^(2.475293)* h^(0.300022))
IF_simple <- indvol(x = simple1, mens="plot", myeq = "0.000065661*d^2.475293*h^0.300022")

#Using a form factor

Expand Down

0 comments on commit efee0aa

Please sign in to comment.