0

I have some data taken from a driving simulation in which we are trying to measure brake reaction time. Using the sample data below for context, the columns I am interested in are time, brake (range 0-1; represents the force applied to the brake pedal )and distance along road. In the driving scenario, the subjects drives along a straight road and at 460 meters (distance along road value) an event begins. The first value of interest is the corresponding value in the time column to represent when this event starts. The second value we want to identify is the time at which the brake value goes above 0.2. The difference between these two points (using values from the time column) will give us a reaction time.

I am very new to using R and so far I have been able to identify the first value of interest using the code Log$V1[Log$V5==460]. However, this hasn't been a huge help because often the value in the distance along road column is not an integer and will have several decimal places. So I would really be looking to locate the distance between say 460 and 461.

If anyone could point me in the right direction that would be great as I am quite stuck.

Thanks.

enter image description here

Phil
  • 7,287
  • 3
  • 36
  • 66
  • 1
    Your first row is actually the variable names, so you'd first need to review how you imported the data. – Phil Mar 08 '20 at 00:13
  • Please add data using `dput` and show the expected output for the same. Please read the info about [how to ask a good question](http://stackoverflow.com/help/how-to-ask) and how to give a [reproducible example](http://stackoverflow.com/questions/5963269). – Ronak Shah Mar 08 '20 at 01:30

1 Answers1

0

We can use the cut function to create 'bins' to 'discretesize' a continuous variable:

cut(cars$dist, breaks = seq(1, 100, 20))

Returns:

 [1] (1,11]  (1,11]  (1,11]  (21,31] (11,21] (1,11]  (11,21] (21,31] (31,41] (11,21] (21,31]
[12] (11,21] (11,21] (21,31] (21,31] (21,31] (31,41] (31,41] (41,51] (21,31] (31,41] (51,61]
[23] (71,81] (11,21] (21,31] (51,61] (31,41] (31,41] (31,41] (31,41] (41,51] (41,51] (51,61]
[34] (71,81] (81,91] (31,41] (41,51] (61,71] (31,41] (41,51] (51,61] (51,61] (61,71] (61,71]
[45] (51,61] (61,71] <NA>    <NA>    <NA>    (81,91]
Levels: (1,11] (11,21] (21,31] (31,41] (41,51] (51,61] (61,71] (71,81] (81,91]

Also: It would make it easier to give you a good answer if you posted a minimal reproducible example instead of an image of data. this is another excellent source of information for getting good answers.

Edward
  • 10,360
  • 2
  • 11
  • 26
dario
  • 6,415
  • 2
  • 12
  • 26