yrfraction function

Fraction of the Year

Fraction of the Year

Calculate the fraction of the year for a date variable (after accounting for leap years) or for month.

yrfraction(date, type = "daily")

Arguments

  • date: a date variable if type=‘daily’ , or an integer between 1 and 12 if type=‘monthly’ .
  • type: daily for dates, or ‘monthly’ for months.

Returns

  • yrfrac: Fraction of the year.

Details

Returns the fraction of the year in the range [0,1).

Examples

# create fractions for the start, middle and end of the year date = as.Date(c(0, 181, 364), origin='1991-01-01') # create fractions based on these dates yrfraction(date) yrfraction(1:12, type='monthly')

Author(s)

Adrian Barnett a.barnett@qut.edu.au

  • Maintainer: Adrian Barnett
  • License: GPL (>= 3)
  • Last published: 2022-03-21

Useful links