-
Notifications
You must be signed in to change notification settings - Fork 0
/
loadData.R
43 lines (40 loc) · 1.02 KB
/
loadData.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
loadUI <- function(id, label = 'loadData'){
ns <- NS(id)
fluidPage(
shinydashboard::box(
title = 'Data Upload', width = 3, status = 'primary',
fileInput(
inputId = ns('localfile'),
label = 'Upload a meter data',
accept = c('.csv', '.tsv')
),
div(style = 'margin-top:-25px'),
a(href = '', 'Example Data', download = NA, target = '_blank')
),
shinydashboard::box(
title = 'Data Table', width = 9, status = 'warning',
DT::dataTableOutput(
outputId = ns('tableOutput')
)
)
)
}
loadServer <- function(id){
moduleServer(
id,
function(input, output, session){
dat <- reactive({
if(!is.null(input$localfile$datapath)){
fread(input$localfile$datapath)
}else{
readRDS('meterData.rds')
}
})
output$tableOutput <- DT::renderDataTable({
req(dat())
DT::datatable(dat(), options = list(scrollX = T, scrollCollapse = T))
})
return(dat)
}
)
}