0

CSV File

I am trying to find the duration in seconds between adjacent time stamps. The first issue I am having is that I am not sure if it is treating each timestamp as a number, I tried using

TimeStamp <- read.csv("DateStamps.csv", header = TRUE, colClasses = "character") 

However, I am not sure if it is working, because, on empty spaces, where there should be an NA, there is nothing.

For the differences, I want to find 4 durations in seconds, (gather order - start, walk to car - gather order, handoff - walk to car, return to store - handoff) all of this through adjacent columns. However, I am not sure how to do this, or how to write a piece of code that would recognize the specific differences I want to calculate.

Akshit
  • 424
  • 4
  • 15
Away-Zone
  • 1
  • 2
  • 1
    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. Pictures aren't helpful because we can't copy/paste the data into R. Instead share `dput(TimeStamp)`. Show the code you tried. – MrFlick Aug 17 '20 at 02:54
  • 1
    Those appear to be strings, not `POSIXt` (R's idea of a timestamp). You can use the `lubridate`, `zoo`, or even `data.table` packages to deal with "time-of-day only", or you can use base R with `as.POSIXct` and some string pasting to fake a date in that string. There are other questions that may help: https://stackoverflow.com/q/31710890/3358272 and https://stackoverflow.com/q/7492247/3358272. – r2evans Aug 17 '20 at 03:32

1 Answers1

-1

I think the NA issue is answered here: Change the Blank Cells to "NA"

You need to stipulate to R what constitutes NA