[R] Problem with Julian function

From: Devred, Emmanuel <DevredE_at_mar.dfo-mpo.gc.ca>
Date: Thu 15 Jun 2006 - 21:50:44 EST


Dear all,

I have a problem with the function Julian, may be a bug in the function ? Here is a vector of character, which represents dates (May 18 to May 20 2000):

 > amj <- c("2000-05-18","2000-05-18","2000-05-18","2000-05-19","2000-05-19"  > ,"2000-05-19", "2000-05-19", "2000-05-20", "2000-05-20", "2000-05-20")

I load the date and chron libraries, I define the vector of character as a date variable using the dates function:

> ymd <- dates(amj,format=c(dates="y-m-d"),origin=c(month=1,
day=1,year=2000))

Then when I apply the Julian function:

> julian(months(ymd),days(ymd),years(ymd),origin=c(month = 1, day = 1, year
= as.numeric(years(ymd[1]))))

I get the following result:

[1] 137 137 137 138 138 138 138 139 139 139

However, when I check on the calendar, the dates I have correspond to the 139th, 140th and 141st days of the year (there is a two days shift because it is a leap year, for other years I have a one day shift). I tried the default origin when I use the dates function but I get the same results.

Did anyone have this problem before ? I would appreciate some help,

  Thank you very much,

       Emmanuel

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jun 15 23:08:04 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 16 Jun 2006 - 02:12:53 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.