I am trying to convert a date into a julian date. I have this data frame
diff yr mo dy hr
1 3.174583 1873 12 1 1
2 2.874583 1873 12 1 3
3 2.574583 1873 12 1 5
4 2.074583 1873 12 1 7
5 1.774583 1873 12 1 9
6 1.474583 1873 12 1 11
and for every row I want to assign the number of days since a particular date (e.g. "1870-01-01").
I tried like this
julian(as.Date(paste(dep$yr,dep$mo,dep$dy,sep="/"),"%Y/%m/%d"))
but this gives me the days since "1970-01-01".. If I try to set the origin
julian(as.Date(paste(dep$yr,dep$mo,dep$dy,sep="/"),"%Y/%m/%d"),origin = paste(1870,1,1,sep="-"))
then I get this error
Error in unclass(x) - unclass(origin) :
non-numeric argument to binary operator
Can some one help me?
Many thanks
julian()
you will notice that you need to specify the origin which is1970-01-01
by default. – Andriejulian(as.Date("1873-12-01"), origin = as.Date("1870-01-01"))
. Your origin should be a Date, not a string. – Andrie