Lubridate yday starting day1 in the middle of the year?

9 weergaven
Naar het eerste ongelezen bericht

Meghan Sauro

ongelezen,
26 nov 2020, 19:45:2926-11-2020
aan 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

ongelezen,
6 jan 2023, 12:03:3506-01-2023
aan 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.


Allen beantwoorden
Auteur beantwoorden
Doorsturen
0 nieuwe berichten