[R] days between dates

armstrwa William.Armstrong at noaa.gov
Mon May 23 18:56:22 CEST 2011


Geoff,

I think you could write an if loop to solve this.

You could write:

for(i in 1:num_obs){

if(DAYS[i]=='Monday'){
DF$DAYS.BETWEEN[i]<-1
}
}

Where 'num_obs' is the total number of temperature observations you have. 
This would only be correct if you had no missing data on Fridays.  Also, if
you had any missing Mondays, the Tuesday 'DAYS.BETWEEN' would be a 5 instead
of a 2.

Maybe there's a better way to do this, but I think this should work as long
as you have a pretty complete record.

Billy

--
View this message in context: http://r.789695.n4.nabble.com/days-between-dates-tp3544335p3544643.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list