Import light glasses acceptability

Author

Johannes Zauner

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)
files <- files |> 
          subset(grepl("mTFA", files))
#import files
data <- 
  read_csv(files, show_col_types = FALSE) |> 
    rename_with(\(x) str_remove_all(x, "_v2")) |> 
  drop_na(redcap_repeat_instance)
#check column types
coltype_check <- coltype_checker(codebook, data)
coltype_check$details |> gt()
col expected present actual type_ok issue expected_example
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
Light glasses acceptability N N = 231
How comfortable did you feel while wearing the light glasses? 23
    Very uncomfortable
2 (8.7%)
    Uncomfortable
7 (30%)
    No opinion
2 (8.7%)
    Comfortable
12 (52%)
    Very comfortable
0 (0%)
How much effort did it take to wear and use the light glasses during the 7 days? 23
    No effort at all
1 (4.3%)
    A little effort
15 (65%)
    No opinion
1 (4.3%)
    A lot of effort
6 (26%)
    Huge effort
0 (0%)
There are moral or ethical consequences to wearing the light glasses 23
    Strongly disagree
7 (30%)
    Disagree
7 (30%)
    No opinion
5 (22%)
    Agree
3 (13%)
    Strongly agree
1 (4.3%)
Wearing light glasses can measure individuals' light exposure in their daily life 23
    Strongly disagree
0 (0%)
    Disagree
3 (13%)
    No opinion
5 (22%)
    Agree
9 (39%)
    Strongly agree
6 (26%)
It is clear to me how wearing the light glasses will help inform my light exposure 23
    Strongly disagree
0 (0%)
    Disagree
1 (4.3%)
    No opinion
2 (8.7%)
    Agree
8 (35%)
    Strongly agree
12 (52%)
How confident did you feel while wearing the light glasses? 23
    Very unconfident
0 (0%)
    Unconfident
3 (13%)
    No opinion
3 (13%)
    Confident
13 (57%)
    Very confident
4 (17%)
Wearing the light glasses interfered with my other priorities 23
    Strongly disagree
4 (17%)
    Disagree
14 (61%)
    No opinion
1 (4.3%)
    Agree
2 (8.7%)
    Strongly agree
2 (8.7%)
How acceptable was wearing the light glasses during the 7 days for you? 23
    Completely unacceptable
0 (0%)
    Unacceptable
1 (4.3%)
    No opinion
1 (4.3%)
    Acceptable
19 (83%)
    Completely acceptable
2 (8.7%)
1 n (%)
gtsave(table |> as_gt(), filename = "../output/tables/table_acceptability.png", vwidth = 800)
file:////var/folders/9p/326_k3kx43qbn_cyl1rqfhb00000gn/T//RtmpB2181T/file178897703f689.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")