R/fPOSIX_to_fracyr_null.R

Defines functions fPOSIX_to_fracyr_null

Documented in fPOSIX_to_fracyr_null

#' Convert a vector of POSIX dates to null fractional years, i.e. 1-1.99 is the current proc_yr, 0-0.99 is the previous year, >2 is subsequent years.
#' @export
#' @title Convert POSIX dates to null fractional year
#'
#' @param POSIX date vector, POSIX dates in the format: 'YYY-MM-DD'
#' @param proc_yr numeric vector, array of years denoting the current process_year (process_years may include data from other calendar years, but are centered on a particular year)

#' @importFrom lubridate decimal_date


fPOSIX_to_fracyr_null <- function(POSIX, proc_yr) {

  POSIX <- as.Date(POSIX, "%Y-%m-%d")
  fracyr <- decimal_date(POSIX)
  fracyr_null <- fracyr - (proc_yr - 1)

  return(fracyr_null)
}
ksmiff33/FluxSynthU documentation built on Dec. 15, 2020, 10:29 p.m.