1

I try to analyze some data imported from a .csv spreadsheet. To analyze the data I need to restrict my sample to a certain timeframe (from d.m.Y H:M:S to d.m.Y H:M:S). The time data is in format POSIXlt (converted from character as original input). I am looking for suggestions how to cut this, since my approach does not result in a dataframe, but an empty integer.

    > dF<-NE2A1[1:5,]
    > dF
      Time X.1.oC.0 X.2.pf..do.. X.HK.Temp.oC
      1  18.05.2013 08:29:47  4.93333        1.577        13.80
      2                            NA           NA           NA
      3  18.05.2013 09:00:09  5.10333        1.583        22.63
      4  18.05.2013 10:00:08  5.39333        1.589        31.10
      5  18.05.2013 11:00:07  5.67333        1.593        25.88
      #Converting to POSIXlt format.
      > dF$Time<-strptime(dF$Time, format = "%d.%m.%Y %H:%M:%S")
      #My attempt to select data from a certain timeframe:
      > dF.cut<-which(with(dF, (dF$Time>"2013-05-18 09:00:00"))&(dF$Time<"2013-05-18 11:00:07"))

dails. As it results in the following dF.cut:

     > dF.cut

     integer(0)

Does anybody know a workaround for this problem? I made sure, that dF$Time is of type charakter not factor.

Ronja
  • 21
  • 5
  • How about quotes around dates? – tonytonov Jul 04 '14 at 10:28
  • Thank you! Edited that. However, the resulting dataframe is empty, although it ought contain some values. Suggstions? – Ronja Jul 04 '14 at 15:11
  • Honestly, I thought it was the only required fix. Another possible problem is that your `Time` column is treated like a factor instead of a character vector, with empty string instead of `NA` (like in the second line). `str(dF)` will give a hint what it is. – tonytonov Jul 04 '14 at 21:03

0 Answers0