Dear All
 
I have the following code:
 
datetime <-c("1/1/13 00:00","1/1/13 12:00","1/2/13 00:00","1/2/13 12:00")
datetime <-as.POSIXct(datetime,format='%m/%d/%Y %H:%M')
times 
<-matrix(c(difftime(datetime[2],datetime[1],units="hours"),difftime(datetime[3],datetime[2],units="hours"),difftime(datetime[4],datetime[3],units="hours")))

I would like to aks for some directions on how to make the 'times' object code 
a bit more "uniform" to accept differenth lenths of 'datetime'... Occasionally 
I have the 'datetime' object include up to 15 date and time points, but that 
code limits the system from accepting a longer 'datetime' object. This is what 
that looks like (basically same as above, but much longer): 
 
datetime <-c("1/1/13 00:00","1/1/13 12:00","1/2/13 00:00","1/2/13 12:00")
datetime <-as.POSIXct(datetime,format='%m/%d/%Y %H:%M')
times 
<-matrix(c(difftime(datetime[2],datetime[1],units="hours"),difftime(datetime[3],datetime[2],units="hours"),difftime(datetime[4],datetime[3],units="hours"),difftime(datetime[5],datetime[4],units="hours"),difftime(datetime[6],datetime[5],units="hours"),difftime(datetime[7],datetime[6],units="hours"),difftime(datetime[8],datetime[7],units="hours"),difftime(datetime[9],datetime[8],units="hours"),difftime(datetime[10],datetime[9],units="hours"),difftime(datetime[11],datetime[10],units="hours"),difftime(datetime[12],datetime[11],units="hours"),difftime(datetime[13],datetime[12],units="hours"),difftime(datetime[14],datetime[13],units="hours"),difftime(datetime[15],datetime[14],units="hours"),difftime(datetime[16],datetime[15],units="hours")))

appreciate the help,
 
Andras
        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to