day_of_harvest {cropgrowdays}R Documentation

The day of harvest in the year of sowing

Description

day_of_harvest calculates the day of year of harvest (or another quantity such as petal fall) if harvest occurs in the next year after sowing. For instance, if the sowing date is near the end of the year, then the harvest date will fall in the next year. Hence, the harvest day (as a day of year) will be be smaller than the sowing date (as a day of the year). The day_of_harvest function rectifies this situation by calculating the harvest date as the day of year in the previous year. Hence, the resulting day of year will be greater than 366. Of course, this is not necessary if the sowing and harvest dates are in the same year, in which case day_of_year will provide exactly the same result.

Usage

day_of_harvest(
  x,
  sowing,
  type = c("calendar", "financial", "other"),
  base = NULL,
  verbose = FALSE
)

Arguments

x

A harvest Date used for calculation of the day of the year.

sowing

A sowing Date used for calculation.

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”.

verbose

Logical to indicate whether to indicate data errors. (Default:FALSE)

Value

An numeric vector containing the day of harvest in the year of sowing which will differ from the day of harvest if the sowing date is in the previous year

Examples

library(lubridate)
day_of_harvest(x = ymd("2020-06-15"), sowing = ymd("2020-06-01")) # leap year
day_of_harvest(x = ymd("2021-06-15"), sowing = ymd("2021-06-01")) # not
day_of_harvest(x = ymd("2021-06-15"), sowing = ymd("2020-06-01")) # 366+166
day_of_harvest(x = ymd("2021-02-05"), sowing = ymd("2021-01-28"))
day_of_harvest(x = ymd("2021-02-05"), sowing = ymd("2021-01-28"),
               type = "financial")
day_of_harvest(x = ymd("2021-09-05"), sowing = ymd("2021-01-28"),
               type = "financial") # 67 + 365
## number_of_days(ymd("2021-02-05"), ymd("2020-09-01")) + 1
day_of_harvest(x = ymd("2021-02-05"), sowing = ymd("2021-01-28"),
               type = "other", base = list(m = 9, day = 1))

[Package cropgrowdays version 0.2.1 Index]