I want to subtract to POSIXct. I can do this but depending on the first row (i guess?) the difference will be in seconds or minutes. Below you can see the first diff is in
You can use difftime
for that propose which allows you to specify the measurement units, for example
difftime(t1, t2, units = "secs")
Another way (as mentioned by @nicola and is present in the same documentation) is to take advantage of the fact that -
has a -.POSIXt
method and override the measurement units after the subtraction operation using units<-
replacement method
res <- t1 - t2
units(res) <- "secs"