-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.R
62 lines (54 loc) · 1.4 KB
/
app.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
source("global.R", local = TRUE)
source("common.R", local = TRUE)
# Install or load dependencies
required_packages <- c(
"shiny",
"shinyWidgets",
"DT"
)
LoadRequiredPackages(required_packages)
# UI component
ui <- navbarPage(
"CLOVoc Data Dashboard",
tabPanel(
"Explore Data",
sidebarLayout(
sidebarPanel(
uiOutput("select"),
downloadButton("download", "Download as TSV"),
width = 2
),
mainPanel(DT::dataTableOutput("records"), width = 10)
)
)
)
# server component
server <- function(input, output) {
output$select <- renderUI({
selectInput(
"table",
"Select a Table:",
c("Patient", "Condition", "Specimen", "DocumentReference"),
selected = "Patient"
)
})
data_input <- reactive({
data <- dataset[[input$table]]
return(data)
})
output$download <- downloadHandler(
file_name <- function() {
paste(input$table, "tsv", sep = ".")
},
content <- function(file) {
write.table(
data_input(), file, sep = "\t", row.names = FALSE
)
}
)
output$records <- DT::renderDataTable({
data_input()
}, options = list(pageLength = 25))
}
# Bind UI and server to an application
shinyApp(ui = ui, server = server)