Prepare the tibble in requested format.

Write it to a CSV file.
labels
junos 2021-11-29 17:54:16 +01:00
parent 32025cbd8c
commit 35d9779026
1 changed files with 24 additions and 2 deletions

View File

@ -12,6 +12,12 @@ prepare_participants_file <- function() {
device_id_container <- snakemake@params[["device_id_table"]] device_id_container <- snakemake@params[["device_id_table"]]
start_end_date_container <- snakemake@params[["start_end_date_table"]] start_end_date_container <- snakemake@params[["start_end_date_table"]]
output_data_file <- snakemake@output[["participants_file"]]
platform <- "android"
pid_format <- "p%03d"
datetime_format <- "%Y-%m-%d %H:%M:%S"
participant_data <- read_csv(username_list_csv_location, col_types = "c", progress = FALSE) participant_data <- read_csv(username_list_csv_location, col_types = "c", progress = FALSE)
usernames <- participant_data$label usernames <- participant_data$label
@ -31,7 +37,23 @@ prepare_participants_file <- function() {
participant_data %<>% participant_data %<>%
left_join(start_end_datetimes, by = "participant_id") left_join(start_end_datetimes, by = "participant_id")
return(participant_data) participant_data %<>%
mutate(
pid = sprintf(pid_format, participant_id),
start_date = strftime(datetime_start, format=datetime_format, tz = "UTC", usetz = FALSE), #TODO Check what timezone is expected
end_date = strftime(datetime_end, format=datetime_format, tz = "UTC", usetz = FALSE),
empatica_id = "placeholder", #TODO Provide in file?
device_id = map_chr(device_ids, str_c, collapse = ";"),
number_of_devices = map_int(device_ids, length),
fitbit_id = ""
) %>%
rowwise() %>%
mutate(platform = str_c(replicate(number_of_devices, platform), collapse = ";")) %>%
ungroup() %>%
arrange(pid) %>%
select(pid, label, start_date, end_date, empatica_id, device_id, platform, fitbit_id)
write_csv(participant_data, output_data_file)
} }
prepare_participants_file()