AnnualSeasonalMeans: Calculate the Annual and Seasonal Summary Values from Monthly...

View source: R/AnnualSeasonalMeans.R

AnnualSeasonalMeansR Documentation

Calculate the Annual and Seasonal Summary Values from Monthly ClimateNA Variables

Description

This function uses the monthly variables provided by ClimateNA and constructs the annual and seasonal averages/sums for each variable in new columns of the data frame. Averages are calculated for all temperature, solar radiation, and relative humidity values. Sums are calculated for all other variables. This only works with the CSV option in ClimateNA.

Usage

AnnualSeasonalMeans(
  item,
  var = c("Tmax", "Tmin", "PPT", "DD5", "NFFD", "PAS", "CMI"),
  TmaxMax = FALSE,
  TminMin = FALSE
)

Arguments

item

CSV file containing monthly (NOT primary monthly) ClimateNA variables. You can use primary monthly variables, but you must emphasize which variables to use.

var

Climate variables desired for mean/sum calculations based on annual and seasonal distributions (seasons based on months, not true seasons). Options include : Tmax, Tmin, Tave, PPT, Rad, DD_5, DD5, DD_18, DD18, NFFD, PAS, Eref, CMD, RH, CMI. Mean values are calculated for temperature, solar radiation, and relative humidity. Summed values are calculated for all other variables. Default value indicates only Tmax, Tmin, PPT, DD5, NFFD, PAS, and CMI.

TmaxMax

logical. Use to access maximum values for Tmax variable. Default setting is FALSE (use of the mean value)

TminMin

logical. Use to access minimum values for Tmin variable. Default setting is FALSE (use of the mean value)

Value

An expanded data frame

Author(s)

Michael Burnett - UBC Faculty of Forestry

Examples

### Processing a single file
#files <- list.files(pattern='*csv$')
#site <- read.csv(files[1])
#annSeaMean <- AnnualSeasonalMeans(site,c('Tmax','Tmin','PPT','CMI'))

## Processing multiple files
files <- list.files(pattern='*csv$')
for(i in files){
  item <- read.csv(i)
  item <- AnnualSeasonalMeans(item)
  write.csv(item,i)
}

Silva21-irss/silvR21 documentation built on Sept. 14, 2022, 7:55 a.m.