Axis x minute by minute [closed]

-1

I need to identify and quantify time slots longer than 5 minutes from an extended column. "Time" column. Follow dput :

structure(list(Time = structure(c(1541062677, 1541062678, 1541062680, 
1541062681, 1541062681, 1541062683, 1541062685, 1541062686, 1541062688, 
1541062688), class = c("POSIXct", "POSIXt"), tzone = ""), CIDM = 
c(0.12146956236827, 
0.24293912473654, 0.337352282020179, 0.431765439303817, 0.553235001672087, 
0.674704564040357, 0.769117721323995, 0.863530878607634, 0.985000440975904, 
1.10647000334417)), .Names = c("Time", "CIDM"), row.names = 142320:142329, 
class = "data.frame")
    
asked by anonymous 05.11.2018 / 18:20

1 answer

4

First an example with a line with time greater than five minutes:

set.seed(321)
CI <- data.frame(
  Time = as.POSIXct(sort(sample(1541062677:1541063688, 10)), origin = '1970-01-01 00:00.00 UTC'),
  CIDM = c(0.12146956236827, 0.24293912473654, 0.337352282020179, 0.431765439303817, 0.553235001672087, 0.674704564040357, 0.769117721323995, 0.863530878607634, 0.985000440975904, 1.10647000334417)
)

The POSIX class is defined as the number of seconds from a reference date (January 1, 1970 by default); so it appears as integers when you run dput. Identifying rows with an interval greater than five minutes is simple using diff :

> CI[diff(CI$Time) > 5*60, ]
                Time      CIDM
7 2018-11-01 10:05:32 0.7691177

That is, the interval between lines 7 and 8 is more than five minutes.

For good control of the display of dates and times in graphs, the most practical is to use ggplot2 and scales :

library(ggplot2)
library(scales)

ggplot(CI, aes(Time, CIDM)) +
  geom_line() + geom_point() +
  scale_x_datetime(minor_breaks = date_breaks("5 min"), date_labels = '%M:%S')

    
06.11.2018 / 22:06