Re: [R] Bus stop sequence matching problem

2014-08-31 Thread Adam Lawrence
Thank you for the help everyone, it has been a very helpful but steep learning curve for me. I have ended up doing a loop as suggested by David as I could understand this a bit better and seems can apply more generally. I have set out my solution below in case that helps anyone. I am interested th

Re: [R] Bus stop sequence matching problem

2014-08-30 Thread Charles Berry
Adam Lawrence gmail.com> writes: > > I am hoping someone can help me with a bus stop sequencing problem in R, > where I need to match counts of people getting on and off a bus to the > correct stop in the bus route stop sequence. I have tried looking > online/forums for sequence matching but see

Re: [R] Bus stop sequence matching problem

2014-08-30 Thread David McPearson
Homework? The list has a no homework policy - but perhaps I'll be forgiven por posting hints. In general terms, this is how I appraoched the problem: * Loop through the rows of stop_onoff - for (idx in ...someething...) {... * For each row, find the first of "ref" in a suitably filtered subset of s

Re: [R] Bus stop sequence matching problem

2014-08-30 Thread Gabor Grothendieck
Try dtw. First convert ref to numeric since dtw does not handle character input. Then align using dtw and NA out repeated values in the alignment. Finally zap ugly row names and calculate loading: library(dtw) s1 <- as.numeric(stop_sequence$ref) s2 <- as.numeric(factor(as.character(stop_onoff$r

[R] Bus stop sequence matching problem

2014-08-29 Thread Adam Lawrence
I am hoping someone can help me with a bus stop sequencing problem in R, where I need to match counts of people getting on and off a bus to the correct stop in the bus route stop sequence. I have tried looking online/forums for sequence matching but seems to refer to numeric sequences or DNA matchi