I want to convert dates into Julian day
x <- c('5/5/2007')
# convert to day of year (Julian date)
strptime(x, "%m/%d/%Y")$yday+1
#125
There are two things I do not understand in this:
1) What is y$day + 1
doing?
When I run it for more dates, it gives me NA for some dates.
date<-c("09/06/1997","01/06/1998","26/05/1999","02/06/2000","01/06/2001","06/06/2002","05/06/2003",
"21/05/2004","16/06/2005","27/05/2006","08/06/2007","09/06/1997","01/06/1998")
strptime(date, "%m/%d/%Y")$yday+1
[1] 249 6 NA 37 6 157 126 NA NA NA 218 249 6
I am not sure why is this happening? And why do we need $yday+1