-
Notifications
You must be signed in to change notification settings - Fork 2
/
00_init.R
49 lines (41 loc) · 1.15 KB
/
00_init.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
library(EczemaPredPOSCORAD)
library(EczemaPred)
library(HuraultMisc)
# library(TanakaData)
library(tidyverse)
library(cowplot)
library(here)
library(rstan)
# rstan_options(auto_write = TRUE) # Save compiled model
options(mc.cores = parallel::detectCores()) # Parallel computing
# Data processing ---------------------------------------------------------
#' Load Derexyl or PFDC dataset containing POSCORAD
#'
#' - Remove patients with less than x=5 observations
#' - Regenerate patient ID (BEWARE for comparisons with other datasets!)
#'
#' This function requires the proprietary package `TanakaData`, except when `dataset = "Fake"`.
#'
#' @param dataset Name of the dataset
#'
#' @return
#'
#' @import dplyr
load_dataset <- function(dataset = c("Derexyl", "PFDC", "Fake")) {
dataset <- match.arg(dataset)
if (dataset == "Derexyl") {
out <- TanakaData::POSCORAD_Derexyl
}
if (dataset == "PFDC") {
out <- TanakaData::POSCORAD_PFDC
}
if (dataset == "Fake") {
out <- EczemaPredPOSCORAD::FakeData$Data
}
out <- out %>%
group_by(Patient) %>%
filter(n() >= 5) %>%
mutate(Patient = cur_group_id()) %>%
ungroup()
return(out)
}