Вопрос

So I have a series of values in two columns in this format

6/14/1998 17:30 | 6/16/1998 1:45

I would like to calculate the time between this two timestamps in R.

Basically, calculate the number of hours between t1 and t2. Could you please help?

Thanks!

Это было полезно?

Решение

Elementary, and covered a million times:

R> difftime(strptime("6/16/1998 01:45", "%m/%d/%Y %H:%M", tz="UTC"),
+           strptime("6/14/1998 17:30", "%m/%d/%Y %H:%M", tz="UTC"),
+           unit="min")     
Time difference of 1935 mins
R> 

See help(difftime) and help(strptime).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top