0

I have a csv file that contains many thousands of timestamped data points. The file includes the following columns: Date, Tag, East, North & DistFromMean. The following is a sample of the data in the file:

enter image description here

The data is recorded approximately every 15 minutes for 12 tags over a month. What I'm wanting to do is select from the data, starting from the first date entry, subsets of data i.e. every 3 hours but due to the tags transmitting at slightly different rates I need a minimum and maximum value start and end time.

I have found the a related previous question but don't understand the answer enough to implement.

The solution could firstly ask for the Tag number, then the period required perhaps in minutes from the start time (i.e. every 3hrs or 180 minutes), the minimum time range and the maximum time range, both of which would be constant for whatever time period was used. The minimum and maximum would probably need to be plus and minus 6 minutes from the period selected.

As the code below shows, I've managed to read in the file, change the Date format to POSIXlt and extract data within a specific time frame but the bit I'm stuck on is extracting the data every nth minute and within a range.

TestData<- read.csv ("TestData.csv", header=TRUE, as.is=TRUE)
TestData$Date <- strptime(TestData$Date, "%d/%m/%Y %H:%M")
TestData[TestData$Date >= as.POSIXlt("2014-02-26 7:10:00") & TestData$Date < as.POSIXlt("2014-02-26 7:18:00"),]
Community
  • 1
  • 1
  • Hi, a bit hard to get to the point. Do you think you can focus the question (what doesn't work) and edit out other parts (background, was does work)? – JNF Mar 31 '15 at 04:37
  • Thanks JNF and sorry for the confusion. It would be easier if I could attach an example file but don't know how. The file has about 3000 records for each of the 12 tags over 28 days. Each tag has a record/row of data about every 15 minutes but it varies so 6 minutes either side should capture all data. I would like to extract from the data subsets i.e. for each tag only those records that are every 3 hours for instance rather than every 15 minute record. Hope this helps. – user3724799 Mar 31 '15 at 04:55

0 Answers0