R/temp_neige.R

#' Day with or without snow
#'
#' Calculate GDD and FDD parameters values from a data.frame containing daily parameters of temperature
#'
#' @param data An object of class "data.frame"containing daily maximum and minimum temperature with a column with dates in format POSIXct.
#' @param Dcol an integer indicates the column number where the daily time is stored.
#' @param tmax an integer indicates the column number where the daily maximum temperature are stored.
#' @param tmin an integer indicates the column number where the daily minimum temperature are stored.
#' @param threshold  value to consider as minimum temperature variation if there is snow
#'
#' @return A data.frame which contains date associate with daily average temperature, gdd and fdd index.
#' @references Choler, P. 2018. Winter soil temperature dependence of alpine plant distribution: Implications for anticipating vegetation changes under a warming climate. Perspectives in Plant Ecology, Evolution and Systematics 30: 6‑15.
#' @author Remy Moine <remymoine95@gmail.com>
#' @export
#'

temp_neige<-function(data,Dcol,tmax,tmin,threshold){

  Max<-data[,tmax]
  Min<-data[,tmin]

  tmp<-data.frame(Dates=data[,Dcol],Max=Max,Min=Min,Neige=rep(NA,nrow(data)))


  for (i in c(1:nrow(tmp))){
    if(tmp$Max[i]-tmp$Min[i]<threshold) tmp$Neige[i]<-T else tmp$Neige[i]<-F}

tmp
}
remymoine/PTS-R-package documentation built on May 16, 2019, 5:03 a.m.