Lubridate yday starting day1 in the middle of the year?

9 views
Skip to first unread message

Meghan Sauro

unread,
Nov 26, 2020, 7:45:29 PM11/26/20
to lubridate
Hi everyone! I need help. Im new to R and I have a hydrometric project working with water (discharge) data. I need my year to actually go from July to June not January to December, so how do I tell r using Lubridate that my yday #1 needs to start in July? I need to be able to take annual averages from my daily data.

Any help is much appreciated!


Meghan

Shivam Shrotriya

unread,
Jan 6, 2023, 12:03:35 PM1/6/23
to lubridate
A solution I posted at https://stackoverflow.com/questions/64435367/change-the-start-date-of-function-lubridateyday/75033896#75033896 

day_vec <- seq(as.Date("2020-07-01"), as.Date("2021-06-30"), by = "days") 
day_vec2 <- day_vec %m-% months(6) #Substracting because the new year will start 6 months later 
yday(day_vec2) #New dates will have the desired yday.

The point to keep in mind is whether your new beginning of the year is before or after the conventional beginning. If your year starts early, you should add months and vice-versa.


Reply all
Reply to author
Forward
0 new messages