Preface
This document imports the acceptability (of light glasses) and shows descriptive statistics for the site.
Setup
library(tidyverse)
library(LightLogR)
Warning: package 'LightLogR' was built under R version 4.5.2
library(glue)
library(readxl)
library(gt)
library(gtsummary)
remote <-
"https://raw.githubusercontent.com/MeLiDosProject/Data_Metadata_Conventions/main/scripts/"
c("labeling",
"radio_factors",
"add_label",
"prepare_codebook",
"filefinder",
"general_parameters",
"coltype_checker",
"tables"
) |> walk(\(x) source(paste0(remote, x, ".R")))
Preparation
#collect codebook
codebook <-
prepare_codebook("MeLiDosDischargeQuestionnaire_DataDictionary_2024-10-16.csv",
"light_glasses_acceptability_modified_tfa_acceptabi")
#collect files
files <- filefinder("discharge",individual = FALSE)
#import files
data <-
read_csv2(files, show_col_types = FALSE) |>
mutate(record_id = paste0("MPI_S", record_id)) |>
filter(!redcap_survey_identifier %in% c(200, 217))
ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
#check column types
coltype_check <- coltype_checker(codebook, data)
coltype_check$details |> gt()
| affective_attitude |
numeric |
TRUE |
numeric |
TRUE |
ok |
as.numeric(...) |
| burden |
numeric |
TRUE |
numeric |
TRUE |
ok |
as.numeric(...) |
| ethicality |
numeric |
TRUE |
numeric |
TRUE |
ok |
as.numeric(...) |
| perceived_effectiveness |
numeric |
TRUE |
numeric |
TRUE |
ok |
as.numeric(...) |
| intervention_coherence |
numeric |
TRUE |
numeric |
TRUE |
ok |
as.numeric(...) |
| self_efficacy |
numeric |
TRUE |
numeric |
TRUE |
ok |
as.numeric(...) |
| opportunity_costs |
numeric |
TRUE |
numeric |
TRUE |
ok |
as.numeric(...) |
| general_acceptability |
numeric |
TRUE |
numeric |
TRUE |
ok |
as.numeric(...) |
#collect relevant columns
relevant_columns <-
coltype_check$details |>
pull(col) |>
c("record_id")
#select relevant columns
data <- data |> select(any_of(relevant_columns))
#label
data <-
data |>
add_radio_factors(codebook,
var_col = `Variable / Field Name`,
type_col = `Field Type`,
levels_col = `Choices, Calculations, OR Slider Labels`
) |>
add_col_labels(codebook, var_col = `Variable / Field Name`, label_col = `Field Label`)
#reorder variables
data <-
data |>
relocate(record_id, any_of(codebook$`Variable / Field Name`))
data$record_id <- add_label(data$record_id, "Record ID")
Summarize results
table <-
table_general(data, "Light glasses acceptability")
table
| How comfortable did you feel while wearing the light glasses? |
26 |
|
| Very uncomfortable |
|
2 (7.7%) |
| Uncomfortable |
|
15 (58%) |
| No opinion |
|
2 (7.7%) |
| Comfortable |
|
7 (27%) |
| Very comfortable |
|
0 (0%) |
| How much effort did it take to wear and use the light glasses during the 7 days? |
26 |
|
| No effort at all |
|
0 (0%) |
| A little effort |
|
14 (54%) |
| No opinion |
|
2 (7.7%) |
| A lot of effort |
|
8 (31%) |
| Huge effort |
|
2 (7.7%) |
| There are moral or ethical consequences to wearing the light glasses |
26 |
|
| Strongly disagree |
|
8 (31%) |
| Disagree |
|
8 (31%) |
| No opinion |
|
5 (19%) |
| Agree |
|
4 (15%) |
| Strongly agree |
|
1 (3.8%) |
| Wearing light glasses can measure individuals' light exposure in their daily life |
26 |
|
| Strongly disagree |
|
1 (3.8%) |
| Disagree |
|
2 (7.7%) |
| No opinion |
|
2 (7.7%) |
| Agree |
|
12 (46%) |
| Strongly agree |
|
9 (35%) |
| It is clear to me how wearing the light glasses will help inform my light exposure |
26 |
|
| Strongly disagree |
|
0 (0%) |
| Disagree |
|
0 (0%) |
| No opinion |
|
3 (12%) |
| Agree |
|
14 (54%) |
| Strongly agree |
|
9 (35%) |
| How confident did you feel while wearing the light glasses? |
26 |
|
| Very unconfident |
|
1 (3.8%) |
| Unconfident |
|
7 (27%) |
| No opinion |
|
8 (31%) |
| Confident |
|
9 (35%) |
| Very confident |
|
1 (3.8%) |
| Wearing the light glasses interfered with my other priorities |
26 |
|
| Strongly disagree |
|
3 (12%) |
| Disagree |
|
7 (27%) |
| No opinion |
|
5 (19%) |
| Agree |
|
10 (38%) |
| Strongly agree |
|
1 (3.8%) |
| How acceptable was wearing the light glasses during the 7 days for you? |
26 |
|
| Completely unacceptable |
|
0 (0%) |
| Unacceptable |
|
5 (19%) |
| No opinion |
|
4 (15%) |
| Acceptable |
|
16 (62%) |
| Completely acceptable |
|
1 (3.8%) |
gtsave(table |> as_gt(), filename = "../output/tables/table_acceptability.png", vwidth = 800)
file:////var/folders/9p/326_k3kx43qbn_cyl1rqfhb00000gn/T//Rtmp4ibBYm/file3ba652a2eff9.html screenshot completed
Export
data <- data |> rename(Id = record_id)
acceptability <- data
path <- "../data/imported/"
if(!dir.exists(path)) dir.create(path, recursive = TRUE)
save(acceptability, file = "../data/imported/acceptability.RData")