year.length: Calculate the number of days in a year

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Determines the number of days per year using a given calendar.

Usage

1
year.length(x, calendar)

Arguments

x

year or a Date

calendar

calendar, see details

Details

The number of days per year depends on the choice of calendar. Calendar names used in the function are the same defined for the CF conventions, used for netCDF files. If a calendar is not specified (or NULL), then it is assumed to be a proleptic Gregorian calendar (which extends before 1582-10-15). Other accepted calendars are:

Value

Returns a vector the same length as x with the numbers of days corresponding to each year.

Author(s)

Mike Toews

References

http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/cf-conventions.html#calendar

See Also

mkseas, mkann

Examples

1
2
3
4
5
6
7
8
cal <- data.frame(year=c(1899, 1900, 1904, 2000, 2080, 2100))
cal[["Gregorian"]] <- year.length(cal$year)
cal[["Julian"]] <- year.length(cal$year, "julian")
cal[["360_day"]] <- year.length(cal$year, "360_day")
cal[["365_day"]] <- year.length(cal$year, "365_day")
cal[["366_day"]] <- year.length(cal$year, "366_day")

cal

Example output

Loading required package: MASS
  year Gregorian Julian 360_day 365_day 366_day
1 1899       365    365     360     365     366
2 1900       365    366     360     365     366
3 1904       366    366     360     365     366
4 2000       366    366     360     365     366
5 2080       366    366     360     365     366
6 2100       365    366     360     365     366

seas documentation built on May 2, 2019, 4:16 a.m.