Re: [R] for loop problem

2012-04-30 Thread Schreiber, Stefan
That's it. Nice and easy :) Thanks! Stefan -Original Message- From: Tyler Rinker [mailto:tyler_rin...@hotmail.com] Sent: Mon 4/30/2012 6:40 PM To: Schreiber, Stefan; r-help@r-project.org Subject: RE: [R] for loop problem I don't really work with dates but thought I'd pass

Re: [R] for loop problem

2012-04-30 Thread Tyler Rinker
I don't really work with dates but thought I'd pass a solution on.  I think that there some great packages for handling dates though (lubridate) and you may want to convert your data to a true date instead of separate columns. # FUNCTION TO INDEX DATES date.int <- function(month, year, day){

Re: [R] for loop problem

2012-04-30 Thread R. Michael Weylandt
Perhaps this is easier: convert your data to Date objects and use the yday (year day) function from the lubridate package: i.e., something like this: jd <- apply(DAT, 1, function(x) as.Date(paste(x, collapse = " "), format = "%Y %m %d") # Just a guess you might have to debug it a little yday(jd)