-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathserver.R
More file actions
56 lines (38 loc) · 1.2 KB
/
server.R
File metadata and controls
56 lines (38 loc) · 1.2 KB
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
library(shiny)
library(tidyverse)
library(yaml)
source("common.R")
shinyServer(function(input, output, session) {
output$study_format <- renderUI({
selectInput("format", label = h4("Study Format"),
choices = filter(studies, study == input$study)$format)
})
output$specification <- renderPrint({
yaml::yaml.load_file(paste0("data_specifications/",
input$study, "_", input$format,
".yaml"))
})
output$validator_output <- renderPrint({
req(input$file)
fields <- yaml::yaml.load_file(paste0("data_specifications/",
input$study, "_", input$format,
".yaml"))
#
tryCatch(
{
df <- read_csv(input$file$datapath)
cat("Upload successful!\n\n")
},
error = function(e) {
# return a safeError if a parsing error occurs
stop(safeError(e))
}
)
valid <- validate_dataset(fields, df)
if (valid) {
cat("\nDataset is valid!")
} else {
cat("\nDataset is NOT valid, please correct and try again!")
}
})
})