PAaSO/side projects/post_stroke_sleep.R

48 lines
1.5 KiB
R
Raw Permalink Normal View History

2026-08-19 09:27:27 +02:00
# ------------------------------------------------------------------------------
# Setup
# ------------------------------------------------------------------------------
token=names(suppressWarnings(read.csv("/Users/au301842/pss_redcap_token.csv",colClasses = "character")))
uri="https://redcap.au.dk/api/"
library(REDCapR)
library(gtsummary)
source("https://raw.githubusercontent.com/agdamsbo/daDoctoR/master/R/dob_extract_cpr_function.R")
library(lubridate)
# ------------------------------------------------------------------------------
# Data download
# ------------------------------------------------------------------------------
dta <- redcap_read_oneshot(
redcap_uri = uri,
token = token,
forms = "baggrund"
)$data
dta<-dta[!is.na(dta$debut),]
# ------------------------------------------------------------------------------
# Table 1
# ------------------------------------------------------------------------------
vars<-c("kon","age","nihss_acute","diagnosis","psg_performed","interview")
# Mangler tilpassede analyser til NIHSS
dta[dta$record_id %in% 12:26,] |>
tbl_summary(missing = "ifany",
include = all_of(vars),
missing_text="(Missing)"#,
#label = lab_sel(labels_all,tbl1_vars)
)|>
add_n()|>
as_gt() |>
# modify with gt functions
gt::tab_header("Baseline Characteristics") |>
gt::tab_options(
table.font.size = "small",
data_row.padding = gt::px(1))
skimr::skim(dta[dta$record_id %in% 12:26,]) |> gt::gt()