Normalize time data between datasets in R

A possible solution to set both lines to start at 0 secs would be (example on one data.frame but applies to the second the same way):

# one of your test data.frames (note that I included ")
X3500um_15_30_45_tx2rx1 <- data.frame(Time = c("2020-11-03 14:50:00", "2020-11-03 14:50:01"), Raw_Touchpad0_Rx1_Tx2 = c(2702, 2704))

library(dplyr)
library(lubridate)

# The calculation to get a new column of the difference from minimum timestamp
X3500um_15_30_45_tx2rx1 %>% 
  dplyr::mutate(Time = lubridate::as_datetime(Time)) %>% 
  dplyr::mutate(DIF = Time - min(Time))

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top