forked from majaliindberg/Touch_com_asd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0_live_compare-metadata.R
62 lines (51 loc) · 1.76 KB
/
0_live_compare-metadata.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# load libraries ####
library(readxl)
library(dplyr)
library(readr)
library(stringr)
library(tidyr)
# source all .R files in the Rfunctions directory ####
sapply(list.files("Rfunctions", full.names = TRUE), source)
# input path ####
RAW_DATA_FOLDER <- "~/Library/CloudStorage/OneDrive-Linköpingsuniversitet/projects - in progress/Touch Comm ASD/Data/"
# output paths ####
REPORTS_FOLDER <- "Data/reports/"
# ===== MAIN =====
# read metadata from scanned questionnaire files ####
scanned <- read_scanned_filenames(RAW_DATA_FOLDER, "\\.pdf") %>%
mutate(status = "scanned") %>%
pivot_wider(
id_cols = c("group", "PID", "date_paper"),
names_from = document,
values_from = status
) %>%
select(-group)
# read metadata from the communication task ####
comm_task <- read_task_filenames(RAW_DATA_FOLDER, 'comm.*data\\.csv') %>%
group_by(PID,date_computer) %>%
tally() %>%
mutate(comm_task = "completed") %>%
select(-n)
# read metadata from the pleasantness task ####
pleas_task <- read_task_filenames(RAW_DATA_FOLDER, 'pleas.*data\\.csv') %>%
group_by(PID,date_computer) %>%
tally() %>%
mutate(pleas_task = "completed") %>%
select(-n)
# read notes about the experiment ####
notes <- read_tsv(paste0(RAW_DATA_FOLDER, "missing-data-notes.txt"))
# save a report giving an overview of the data set ####
computer_tasks <- full_join(comm_task, pleas_task)
full_join(computer_tasks, scanned) %>%
left_join(notes) %>%
mutate(
date_conflict = if_else(
!is.na(date_paper) & !is.na(date_computer) & date_paper != date_computer,
TRUE,
FALSE
),
comment = replace_na(comment, "")
) %>%
select(c("PID", starts_with("date"), everything())) %>%
arrange(PID) %>%
write_path_csv(REPORTS_FOLDER, "live_metadata-comparison.csv")