date_from_day_year: Calculate a date from the day of the year and the year

Description Usage Arguments Value Examples

View source: R/day_of_year.R

Description

date_from_day_of_year returns the date using the day of the year and a year for a calendar or financial year. The first day of the year is 1 January for the calendar year, 1 July for the Australian financial year or can be specified. Alternatively, the first day of the year can be any day of the year if desired.

Usage

1
2
3
4
5
6
date_from_day_year(
  day,
  year,
  type = c("calendar", "financial", "other"),
  base = NULL
)

Arguments

day

Day as an numeric (integer) used for calculation the date

year

Year as an integer (integer) used for calculation the date

type

A character string specifying the type of year. “calendar” is a calendar year starting on 1 January, “financial” an Australian financial year beginning on 1 July and “other” is for a year starting on another date which is specified in base. Default: “calendar”

base

A list specifying the day and month of the first day to be used in calculations. The name of the day component must be named either “day” or “d”, and the month must be named either “month” or “m”.

Value

A date of class Date calculated from the day of the year and the year

Examples

1
2
3
4
5
6
library(lubridate)
date_from_day_year(day = 366, year = 2020)
date_from_day_year(21,2021)
date_from_day_year(day = c(21, 24, 30), year = rep(2021, 3))
date_from_day_year(21,2021, type = "financial")
date_from_day_year(21,2021, type = "other", base = list(d=1, m=9))

cropgrowdays documentation built on Dec. 11, 2021, 9:23 a.m.