2

I have observation data which only give hour and minute mark, the data looks like this:

 - date       | time | value
 - 2019-01-01 | 00:00 | 14
 - 2019-01-01 | 00:30 | 23
 - 2019-01-01 | 01:00 | 32
 - 2019-01-01 | 01:30 | 41
 - 2019-01-02 | 00:00 | 41
 - 2019-01-02 | 00:30 | 32
 - 2019-01-02 | 01:00 | 23
 - 2019-01-02 | 01:30 | 14
 - ....

I successfully convert the date into the data format using

data$date <- as.Date(data$date, "%Y/%m/%d")

but when i try to convert the time to its format, i encounter problem, I tried using this:

data$time <- strptime(data$time, "%H:%M")

this give me the result of time with current date: "2019-03-14 00:00:00". which is not what i'm looking for and the date is false

I also tried using:

trydata$jam <- timestamp(trydata$jam, "%H:%M")

this give me the result: %H:%M00:00 ------##

What is the best way to do this? I also want to extract the data in certain duration of time (like from 10:00 to 13:00)

Thank You

zx8754
  • 52,746
  • 12
  • 114
  • 209
maulana
  • 23
  • 5

0 Answers0