I need to calculate the processing time for several people who have taken an online test. So for each person there are numerous timestamps (one timestamp per task). The duration of the processing is calculated from the time difference between the smallest and the largest date value. The following example works (student\_1), but it only works if no value is missing (student\_2 and student\_3). Are there any ideas?

```
library(anytime)

number <- c(1, 2, 3)
uniquename <- c("student_1", "student_2",  "student_3")
timestamp_1 <- c(anytime("2020-02-25T12:42:56.476Z"),NA,anytime("2020-02-25T10:05:22.388Z"))
timestamp_2 <- c(anytime("2020-02-25T12:51:22.388Z"),anytime("2020-02-25T12:51:22.388Z"),NA)
timestamp_3 <- c(anytime("2020-02-25T13:00:45.042Z"),anytime("2020-02-25T13:00:45.042Z"),NA)
timestamp_4 <- c(anytime("2020-02-25T13:31:48.073Z"),anytime("2020-02-25T13:31:48.073Z"),NA)
timestamp_5 <- c(anytime("2020-02-25T14:22:57.103Z"),anytime("2020-02-25T15:00:00Z"),anytime("2020-02-25T14:05:00Z"))

df3 <- data.frame(number,
                  uniquename,
                  timestamp_1,
                  timestamp_2,
                  timestamp_3,
                  timestamp_4,
                  timestamp_5)

df3$date_min <- apply(df3[3:7], 1, FUN=min)
df3$date_max <- apply(df3[3:7], 1, FUN=max)

df3$date_min <- anytime(df3$date_min)
df3$date_max <- anytime(df3$date_max)

df3$diff <- difftime(df3$date_min, df3$date_max, units = "mins")
df3$diff <- round(df3$diff,0)
df3$diff <- as.numeric(df3$diff)*(-1)

View(df3)

```