0

I am measuring glucose levels from two devices. Each device puts out a time stamp and a corresponding glucose value every 5 minutes. I wish to align the time and values from both devices in such a way that both times in any row are within 5 minutes of each other. The data frame headers are Ltime Lvalue Rtime Rvalue. I want to create a new data frame with the same headers but with the rows adjusted so that Lvalue and Rvalue are no more than 5 minutes apart. Any times that can not be accommodated are to thrown out.

  • 2
    Welcome on SO! Please read http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – sgibb Mar 17 '14 at 17:46

1 Answers1

0

What you could do is use subset. I don't know how you have that time-stamp appearing. Use the appropriate number for 5

     j<-subset(df,LTime-RTime <=5)
     x<-subset(df,RTime-LTime) <=5)
     rbind(j,x)
user2510479
  • 1,528
  • 13
  • 17
  • Your solution works but my question was poorly stated.Let me try a simple example. Let's suppose the two measuring devices over time are out of sync. The data point for Ltime= 5.00 min is record #50 in the dataframe and Rtime= 5.00 min is record #55. I want the script to match the two in a new dataframe so the information from Ltime=5.00min and Rtime= 5.00 min are together! I also would like the script to match any two Ltime or Rtime that are within 5 minutes of each other in case the times do not match exactly. – user3429864 Mar 18 '14 at 13:52