0

I have a column in my data frame of values formatted as datet time: 2017-09-11 08:00:00 and so forth.

I want to find the earliest date with the earliest time of that date as well as the last (most recent) date with the last time.

I am basically trying to find the range of this column to determine the difference in time.

Thanks!

vpz
  • 984
  • 1
  • 15
  • 26
Angie
  • 183
  • 3
  • 13
  • `range(df$col)` will give you the first and last dates. `diff(range(df$col))` will give you the time difference. If the column is not already formatted as datetime class, run `df$col = as.POSIXct(df$col)` first. – eipi10 Mar 31 '20 at 23:03
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Mar 31 '20 at 23:57
  • I think you can use functions such min and max to do so. – Pablo Cánovas Apr 01 '20 at 08:00

0 Answers0