Search code examples
rvectortimeposixct

How to add 1 minute to each value in a vector in R Studio?


I am currently using a vector to extract certain rows from my data set based off time (formatted as POSIXct):

Vector.Time   <- c('2020-03-06 10:09:11', 
                   '2020-03-06 10:13:11',
                   '2020-03-06 10:18:12')

One of the instruments I am using logs data at the end of each minute, so I need to reference a second vector where 1-minute is added to all the values in the original vector. Is there a simple way of doing this without having to create a new vector?


Solution

  • Use the minutes from lubridate

    library(lubridate)
    as.POSIXct(Vector.Time) + minutes(1)