Skip to contents

The function will calculate time difference between the start of the start_question and the end of the end_question.

Usage

create_duration_from_audit_with_start_end(
  audit_file,
  start_question,
  end_question
)

Arguments

audit_file

a dataframe with a single audit file, it needs start, end, node column

start_question

character vector use for the starting question

end_question

character vector use for the ending question

Value

A dataframe with the duration in ms and duration in minutes.

Details

In case the node appear several time (if the value was changed or with a select multiple) it will take the minimum for the start and the maximum for the end.

If a value is missing (skip logic or question not found), it will return -Inf

Examples

some_audit <- data.frame(
  event = c("form start", rep("question", 5)),
  node = c("", paste0("/xx/question", 1:5)),
  start = c(
    1661415887295, 1661415887301, 1661415890819,
    1661415892297, 1661415893529, 1661415894720
  ),
  end = c(
    NA, 1661415890790, 1661415892273,
    1661415893506, 1661415894703, 1661415896452
  )
)
create_duration_from_audit_with_start_end(some_audit, "question1", "question3")
#>   duration_ms duration_minutes
#> 1        6205              0.1