-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal.R
64 lines (54 loc) · 2.67 KB
/
global.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#### PACKAGES -----
library(shiny)
library(bslib)
library(here)
library(readr)
library(dplyr)
library(stringr)
library(checkmate)
library(DT)
library(shinycssloaders)
library(shinyWidgets)
library(glue)
source("tableFilterPanel.R")
# input directory
DATA_DIRECTORY <- "C:/Users/tburkard/OneDrive - Nexus365/Documents/PETDiagnosticsShiny/exampleData"
#DATA_DIRECTORY <- "exampleData" # to run the app with the mock data or any data that is stored in the data folder
#Please make sure that the results are stored in a separate folder per database
if (!dir.exists(DATA_DIRECTORY)) {
stop(glue("Please make sure the '{DATA_DIRECTORY}' directory exists."))
}
subDirs <- list.dirs(DATA_DIRECTORY, full.names = TRUE, recursive = FALSE)
if (identical(subDirs, character(0))) {
stop(glue("No subdirectories found in '{DATA_DIRECTORY}'. Please make sure to
store the results per database in a separate folder."))
}
# load data from directory, merge csv's for multiple databases
mergeFiles <- function(files) {
results <- dplyr::bind_rows(lapply(files,
FUN = function(filename) {
result <- NULL
if (file.exists(filename)) {
read.csv(filename)
result <- read.csv(filename)
}
}
)
)
return(results)
}
PETOverviewMother <- mergeFiles(file.path(subDirs, "PETOverviewMother.csv"))
AnnualPETOverviewMother <- mergeFiles(file.path(subDirs, "AnnualPETOverviewMother.csv"))
missingSummaryMother <- mergeFiles(file.path(subDirs, "missingSummaryMother.csv"))
unknownSummaryMother <- mergeFiles(file.path(subDirs, "unknownSummaryMother.csv"))
gestationalAgeMatch <- mergeFiles(file.path(subDirs, "gestationalAgeMatch.csv"))
valueDatesAgeDist <- mergeFiles(file.path(subDirs, "valueDatesAgeDist.csv"))
outcomeModeMatch <- mergeFiles(file.path(subDirs, "outcomeModeMatch.csv"))
fetusesLivebornNumber <- mergeFiles(file.path(subDirs, "fetusesLivebornNumber.csv"))
PETOverviewBaby <- mergeFiles(file.path(subDirs, "PETOverviewBaby.csv"))
missingSummaryBaby <- mergeFiles(file.path(subDirs, "missingSummaryBaby.csv"))
fetusIdMatch <- mergeFiles(file.path(subDirs, "fetusIdMatch.csv"))
valueWeightDist <- mergeFiles(file.path(subDirs, "valueWeightDist.csv"))
bitSetOverviewAll <- mergeFiles(file.path(subDirs, "bitSetOverviewAll.csv"))
bitSetOverviewMother <- mergeFiles(file.path(subDirs, "bitSetOverviewMother.csv"))
bitSetOverviewBaby <- mergeFiles(file.path(subDirs, "bitSetOverviewBaby.csv"))