date_from_day_year {cropgrowdays}R Documentation

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

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

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

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))

[Package cropgrowdays version 0.2.1 Index]