On Sep 30, 2011, at 4:47 AM, maxbre wrote:
here is an alternative long and winded solution to the problem
sticking on
the julian function of chron package
test$year <- as.integer(as.character(test$date, "%Y"))
test$month <- as.integer(as.character(test$date, "%m"))
test$day <- as.integer(as.character(test$date, "%d"))
test$hour <- as.integer(as.character(test$date, "%H"))
test$jday <-julian(test$month,test$day,test$year,origin=c(month=1,
day=0,
year=test$year))
thank you all for helping me in sorting out the problem
by the way I like very much this very compact solution
test$doy <- as.POSIXlt(test$date)$yday+1
but on the other hand I'm still struggling to fully understand it,
especially for what is concerning the part after $: so what is $yday
for?
POSIXlt objects are represented as lists. as.POSIXlt will convert a
POSIXct object to that class. The "yday" element is the number of
days that have passed since the first day of the year. The "$"
operator accesses list elements by name.
?DateTimeClasses
?Extract # same as ?"["
if someone would be so kind to explain me this part I would be very
grateful
a newbie in R
lesson learned
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.