I have a time variable in POSXIct format and want to transform it into numeric format, to work with the differences in seconds, but when passing it into numeric format, the seconds appear as negative:
Sys.setenv(TZ='GMT')
time=c("1899-12-31 09:11:37 UTC", "1899-12-31 09:12:34 UTC", "1899-12-31 09:13:04 UTC", "1899-12-31 09:13:34 UTC", "1899-12-31 09:14:04 UTC",
"1899-12-31 09:14:34 UTC", "1899-12-31 09:15:04 UTC", "1899-12-31 09:15:34 UTC", "1899-12-31 09:16:04 UTC", "1899-12-31 09:16:34 UTC")
df<-data.frame(time)
df$time<-as.POSIXct(df$time)
df
time
1 1899-12-31 09:11:37
2 1899-12-31 09:12:34
3 1899-12-31 09:13:04
4 1899-12-31 09:13:34
5 1899-12-31 09:14:04
6 1899-12-31 09:14:34
7 1899-12-31 09:15:04
8 1899-12-31 09:15:34
9 1899-12-31 09:16:04
10 1899-12-31 09:16:34
df$time<-as.numeric(df$time)
df
time
1 -2209042103
2 -2209042046
3 -2209042016
4 -2209041986
5 -2209041956
6 -2209041926
7 -2209041896
8 -2209041866
9 -2209041836
10 -2209041806
How can I transform them as positive? Is this issue linked to the time origin or the date?
Thanks in advance!