How can I convert Julian dates to fit my data ? (eg. January 2nd would be "2" but I need it to be 365 +2 = 367)

26 Views Asked by At

so I am trying to look at day of year that ice is freezing in lakes over time.

I have figured out how to convert my dates into Julian days, however, in some years ice-on is happening in the same year.

eg. lake froze on January 3rd 2014 (which actually represents the year 2013) and the same lake froze December 28th 2014.

So when I convert into Julian dates, that years Julian day is represented by "3". But I need a lake that froze on January 3rd 2014 to be represented by 365 + 3 = 368.

Is there a way I can do this in RStudio? Any help is appreciated.

This is what my data frame (frame1) currently looks like

I cannot seem to find anything online to solve this issue. Here is the code I've used to get to this point.

library(readxl)
library(here) library(janitor) library(tidyverse) library(dplyr) library(lubridate)

frame1 <- readxl::read_excel(here('data/Syke IB 1800-2022 (1).xlsx'), sheet = 2) %>% 
  clean_names() %>%
select(date, lippu) %>%
  mutate(year= year(date),
         month = month(date),
         day = day(date)) %>%
  filter(lippu == "x7" )

frame1$MY.DATE1 <- do.call(paste, list(frame1$year, frame1$month, frame1$day)) %>%
frame1$MY.DATE1 <- as.Date(frame1$MY.DATE1, format=c("%Y %m %d")) %>%
frame1$my.julian.date <- as.numeric(format(frame1$MY.DATE1, "%j")) %>%
frame1
0

There are 0 best solutions below