Import Light sensitivity VLSQ8

Author

Johannes Zauner

Preface

This document imports the VLSQ8 (Light sensitivity) and shows descriptive statistics for the site.

Setup

library(tidyverse)
Warning: package 'ggplot2' was built under R version 4.5.2
Warning: package 'tidyr' was built under R version 4.5.2
Warning: package 'dplyr' was built under R version 4.5.2
library(LightLogR)
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")))
Warning: package 'rlang' was built under R version 4.5.2

Preparation

#collect codebook
codebook <- 
  prepare_codebook("MeLiDosDischargeQuestionnaire_DataDictionary_2024-10-16.csv",
                   "your_light_sensitivity_vlsq8")
#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()
col expected present actual type_ok issue expected_example
sensitivity numeric TRUE numeric TRUE ok as.numeric(...)
glare numeric TRUE numeric TRUE ok as.numeric(...)
flicker numeric TRUE numeric TRUE ok as.numeric(...)
sensitivity_severity numeric TRUE numeric TRUE ok as.numeric(...)
headache numeric TRUE numeric TRUE ok as.numeric(...)
blurry_vision numeric TRUE numeric TRUE ok as.numeric(...)
ability numeric TRUE numeric TRUE ok as.numeric(...)
glasses 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")

Calculate composit score

data <- 
data |> 
  rowwise() |> 
  mutate(VLSQ8 = sum(c_across(sensitivity:glasses) |> as.numeric())) |> 
  ungroup() |> 
  relocate(.after = record_id, VLSQ8)
data$VLSQ8 <- add_label(data$VLSQ8, "VLSQ-8 sum score (light sensitivity)")

Summarize results

table <- 
table_general(data, "VLSQ-8: light sensitivity")
table
VLSQ-8: light sensitivity N N = 261
VLSQ-8 sum score (light sensitivity) 26 18.0 (15.0, 25.0)
How often did you have visual light sensitivity outdoors during daylight? 26
    Never
8 (31%)
    Rarely
8 (31%)
    Sometimes
8 (31%)
    Often
1 (3.8%)
    Always
1 (3.8%)
How often did you have a sense of glare in your eyes? 26
    Never
8 (31%)
    Rarely
9 (35%)
    Sometimes
7 (27%)
    Often
2 (7.7%)
    Always
0 (0%)
How often did you have visual light sensitivity from flickering lights or bright colors? 26
    Never
8 (31%)
    Rarely
9 (35%)
    Sometimes
3 (12%)
    Often
5 (19%)
    Always
1 (3.8%)
Please rate the severity of the worst visual light sensitivity you experienced in the past week. 26
    None
13 (50%)
    Mild
9 (35%)
    Moderate
4 (15%)
    Significant
0 (0%)
    Severe
0 (0%)
When you have sensitivity to light, do you also experience headache? 26
    Never
13 (50%)
    Rarely
6 (23%)
    Sometimes
4 (15%)
    Often
1 (3.8%)
    Always
2 (7.7%)
When you have sensitivity to light, how often is your vision blurry? 26
    Never
14 (54%)
    Rarely
6 (23%)
    Sometimes
4 (15%)
    Often
2 (7.7%)
    Always
0 (0%)
How often does sensitivity to light limit your ability to read, watch TV, or use the computer? 26
    Never
10 (38%)
    Rarely
10 (38%)
    Sometimes
5 (19%)
    Often
1 (3.8%)
    Always
0 (0%)
How often did you need to wear dark glasses on cloudy days or indoors? 26
    Never
22 (85%)
    Rarely
3 (12%)
    Sometimes
1 (3.8%)
    Often
0 (0%)
    Always
0 (0%)
1 Median (Q1, Q3); n (%)
gtsave(table |> as_gt(), filename = "../output/tables/table_vlsq8.png", vwidth = 800)
file:////var/folders/9p/326_k3kx43qbn_cyl1rqfhb00000gn/T//RtmprVDfbw/fileee164ba31573.html screenshot completed

Export

data <- data |> rename(Id = record_id)
vlsq8 <- data
path <- "../data/imported/"
if(!dir.exists(path)) dir.create(path, recursive = TRUE)
save(vlsq8, file = "../data/imported/vlsq8.RData")