My data set includes various observations at different stages throughout the year.
year
when samples were collected. site
location of measurement Class
physical stage during r of measurementdate
date of measurementJulian
Julian dateThe final measurements usually occur in the early part of the new year, which is the summer time in the southern hemisphere. (e.g. summer is winter, spring is fall).
year site Class date Julian
1 2009 10C Early 2008-09-15 259
2 2009 10C L2 2008-09-29 273
3 2009 10C L3 2008-12-15 350
4 2010 10C Early 2009-08-31 243
5 2010 10C L2 2009-09-14 257
6 2010 10C L3 2009-12-11 345
7 2012 10C Early 2011-08-23 235
8 2012 10C L2 2011-09-22 265
9 2012 10C L3 2011-12-03 337
10 2012 10C LSample 2012-03-26 86
11 2013 10C Early 2012-09-07 251
12 2013 10C L2 2012-09-30 274
13 2013 10C L3 2012-12-17 352
14 2014 10C Early 2013-09-02 245
15 2014 10C L2 2013-09-16 259
16 2014 10C L3 2013-12-16 350
17 2014 10C LMid 2014-01-07 7
18 2015 10C Early 2014-09-08 251
19 2015 10C L2 2014-09-30 273
20 2015 10C L3 2014-12-01 335
I am having a difficult time converting/reassigning the Julian start date to July 1st instead of January 1st. The dot plot below illustrates the final sampling that occurs at the beginning of the year (February-March).
The chron
package has an option to reorder the origin
but I cannot get it to work properly with my data.
library(chron)
library(dplyr)
data.date <- data %>%
mutate(July.Julian = chron(date,format = c(dates = "ymd"), options(chron.origin = c(month=7, day=1, year=2008))))
Error in chron(c("2008-09-15", "2008-09-29", "2008-12-15", "2009-08-31", :
misspecified chron format(s) length
or
July.Julian = chron(data$date, format = c(dates = "ymd"), options(chron.origin = c(month=7, day=1, year=2008)))
Error in chron(c("2008-09-15", "2008-09-29", "2008-12-15", "2009-08-31", :
misspecified chron format(s) length
I am trying to start the Julian date as 1 instead of 182.
Thoughts or suggestions are welcome.
Assuming that July.Julian
is supposed to be Julian
days past July 1st:
transform(date.data, July.Julian = as.chron(sprintf("%d-07-01", year)) + Julian)
or
date.data %>% mutate(July.Julian = as.chron(sprintf("%d-07-01", year)) + Julian)
Note that one does not actually need chron here. Just replace as.chron
with as.Date
and either of these work.