37 lines
1.3 KiB
R
37 lines
1.3 KiB
R
library(tidyverse)
|
|
|
|
token=keyring::key_get("talos_redcap_api")
|
|
# keyring::key_set("talos_redcap_api")
|
|
|
|
# REDCapR::redcap_variables(redcap_uri = "https://redcap.au.dk/api/",token = token)
|
|
# inst <- REDCapR::redcap_instruments(redcap_uri = "https://redcap.au.dk/api/",token = token)
|
|
|
|
# REDCapR::redcap_read(redcap_uri = "https://redcap.au.dk/api/",token = token)
|
|
|
|
pase_raw <- REDCapR::redcap_read(redcap_uri = "https://redcap.au.dk/api/",token = token,fields = "record_id",forms = c("pase_0"))
|
|
|
|
## Selecting relevant variables only
|
|
## "(a)x_" variables are notes and excluded.
|
|
## "12_" is not used for scoring
|
|
pase_sel <- pase_raw[["data"]] |> select("record_id",
|
|
contains("_pase"),
|
|
-contains("x_"),
|
|
-contains("12_"))
|
|
|
|
## Last subset to have relevant cleaned PASE data only
|
|
pase <- pase_sel[,c(3:23)]
|
|
|
|
## Function
|
|
source("TALOS data workflow/pase_calc.R")
|
|
|
|
|
|
|
|
|
|
## No work adjustment (older method)
|
|
summary((pase |> pase_calc(adjust_work = FALSE))[,13])
|
|
## With work adjustment (newer method)
|
|
summary((scores <- pase |> pase_calc())[,13])
|
|
|
|
# pase <- pase[sample(seq_len(nrow(pase)),size = 200),]
|
|
# names(pase) <- sub("_0","",sub("talos","sample", names(pase)))
|
|
# saveRDS(pase,"pase.rds")
|