Adds duration from the audit file
add_duration_from_audit.Rd
Wrapper around create_duration_from_audit_with_start_end and create_duration_from_audit_sum_all to add the duration to the dataset.
Usage
add_duration_from_audit(
dataset,
col_name_prefix = "duration_audit",
uuid_column = "uuid",
audit_list,
start_question = NULL,
end_question = NULL,
sum_all = TRUE
)
Arguments
- dataset
dataset to add the duration
- col_name_prefix
string character to be used for the prefix of new columns
- uuid_column
uuid column in the dataset. Default is uuid.
- audit_list
list of dataframe that are the audit file with the uuid of each interview as name of the dataframe.
- start_question
character vector use for the starting question (optional)
- end_question
character vector use for the ending question (optional)
- sum_all
TRUE or FALSE if to add the time with sum all duration
Examples
list_audit <- list(
uuid1 = 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
)
),
uuid2 = 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
)
)
)
some_dataset <- data.frame(
X_uuid = c("uuid1", "uuid2"),
question1 = c("a", "b"),
question2 = c("a", "b"),
question3 = c("a", "b"),
question4 = c("a", "b"),
question5 = c("a", "b")
)
add_duration_from_audit(some_dataset,
uuid_column = "X_uuid",
audit_list = list_audit)|>
knitr::kable()
#>
#>
#> |X_uuid |question1 |question2 |question3 |question4 |question5 | duration_audit_sum_all_ms| duration_audit_sum_all_minutes|
#> |:------|:---------|:---------|:---------|:---------|:---------|-------------------------:|------------------------------:|
#> |uuid1 |a |a |a |a |a | 9058| 0.2|
#> |uuid2 |b |b |b |b |b | 9058| 0.2|
add_duration_from_audit(some_dataset,
uuid_column = "X_uuid",
audit_list = list_audit,
start_question = "question1",
end_question = "question3",
sum_all = FALSE) |>
knitr::kable()
#>
#>
#> |X_uuid |question1 |question2 |question3 |question4 |question5 | duration_audit_start_end_ms| duration_audit_start_end_minutes|
#> |:------|:---------|:---------|:---------|:---------|:---------|---------------------------:|--------------------------------:|
#> |uuid1 |a |a |a |a |a | 6205| 0.1|
#> |uuid2 |b |b |b |b |b | 6205| 0.1|
add_duration_from_audit(some_dataset,
uuid_column = "X_uuid",
audit_list = list_audit,
start_question = "question1",
end_question = "question3",
sum_all = TRUE) |>
knitr::kable()
#>
#>
#> |X_uuid |question1 |question2 |question3 |question4 |question5 | duration_audit_sum_all_ms| duration_audit_sum_all_minutes| duration_audit_start_end_ms| duration_audit_start_end_minutes|
#> |:------|:---------|:---------|:---------|:---------|:---------|-------------------------:|------------------------------:|---------------------------:|--------------------------------:|
#> |uuid1 |a |a |a |a |a | 9058| 0.2| 6205| 0.1|
#> |uuid2 |b |b |b |b |b | 9058| 0.2| 6205| 0.1|