The problem is resolved already. Please don't include this question in future mailing list
Umair Durrani email: umairdurr...@outlook.com > Subject: Re: [R] Detecting Vehicle locations using R > From: jdnew...@dcn.davis.ca.us > Date: Thu, 20 Feb 2014 20:06:28 -0800 > To: umairdurr...@outlook.com; r-help@r-project.org > > Please read the Posting Guide, which offers several applicable tips, such as: > Don't post in HTML format... it tends to corrupt your code samples. > Please provide a hand-generated example result that should be what the > solution should transform your sample data into. > Please show the code that did not work... you may be closer to the solution > than you think, or we may see from it that you could benefit from learning a > concept you don't know exists yet. This is not supposed to be a forum that > does your work for you. > --------------------------------------------------------------------------- > Jeff Newmiller The ..... ..... Go Live... > DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... > Live: OO#.. Dead: OO#.. Playing > Research Engineer (Solar/Batteries O.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --------------------------------------------------------------------------- > Sent from my phone. Please excuse my brevity. > > On February 20, 2014 6:30:37 PM PST, umair durrani <umairdurr...@outlook.com> > wrote: > >I have a data frame of vehicle trajectories. Here's a snapshot: > >>dput(head(df))structure(list(vehicle = c(2L, 2L, 2L, 2L, 2L, 2L), > >frame = 43:48, globalx = c(6451214.156, 6451216.824, 6451219.616, > >6451222.548, 6451225.462, 6451228.376), class = c(2L, 2L, 2L, 2L, > >2L, 2L), velocity = c(37.76, 37.9, 38.05, 38.18, 38.32, 38.44 ), > >lane = c(2L, 2L, 2L, 2L, 2L, 2L)), .Names = c("vehicle", "frame", > >"globalx", "class", "velocity", "lane"), row.names = c(NA, 6L), class = > >"data.frame") > >where, vehicle= vehicle id, frame= frame id of time frames in which it > >was observed, globalx = x coordinate of the front center of the > >vehicle, class=type of vehicle (1=motorcycle, 2=car, 3=truck), > >velocity=speed of vehicles in feet per second, lane= lane number (there > >are 6 lanes).The 'frame' represents one tenth of a second i.e. one > >frame is 0.1 seconds long. At frame 't' the vehicle has globalx > >coordinate x(t) and at frame 't-1' (0.1 seconds before) it was x(t-1). > >If the reference location has globalx coordinate=6451179.1116 then I > >simply want a new column in df called 'u' which has 'yes' in the row > >where globalx of the vehicle was greater than reference coordinate at > >'U' AND the previous consecutive globalx coordinate of this vehicle was > >less than reference coordinate at 'U'(i.e. reference coordinate is > >between the 2 locations of vehicle in two consecutive frames). This > >means that if df has 100 vehicles then there will be 100 'yes' in 'u' > >column because every vehicle wil! > > > > > >l meet the above criteria only once. I have tried to do this by running > >the function with ifelse and also tried to do the same using a for loop > >but it doesn't work for me. > > > > > > > > [[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. > [[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.