Pregunta

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!

¿Fue útil?

Solución

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).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top