Re: [R] run a calculation function over time fields, ordered and grouped by variables

2015-05-25 Thread jdnewmil
Another way: #create four columns with route id, stop sequence interval time and route start time ssq <- c( 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 2, 3, 4, 5, 6, 7, 8 ) tint <- c( "00:00", "00:12", "00:03", "00:06", "00:09", "00:02", "00:04" , "00:00", "00:08", "00:10", "00:10" , "0

Re: [R] run a calculation function over time fields, ordered and grouped by variables

2015-05-25 Thread Jim Lemon
Hi gavinr, Perhaps this will do what you want. add_HH_MM<-function(x) { t1bits<-strsplit(as.character(x$tst),":") t2bits<-strsplit(as.character(x$tint),":") hours<-as.numeric(lapply(t1bits,"[",1))+cumsum(as.numeric(lapply(t2bits,"[",1))) minutes<-as.numeric(lapply(t1bits,"[",2))+cumsum(as.nu

[R] run a calculation function over time fields, ordered and grouped by variables

2015-05-25 Thread gavinr
I’ve got some transit data relating to bus stops for a GIS data set. Each row represents one stop on a route. For each record I have the start time of the route, a sequence in which a bus stops, the time the bus arrives at the first stop and the time taken to get to each of the stops from the las