-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathcsv_import.R
More file actions
39 lines (32 loc) · 970 Bytes
/
Copy pathcsv_import.R
File metadata and controls
39 lines (32 loc) · 970 Bytes
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
# Module UI function
csvFileInput <- function(id, label = "CSV file") {
# Create a namespace function using the provided id
ns <- NS(id)
tagList(
fileInput(ns("file"), label),
checkboxInput(ns("use_example"), "use example Data")
)
}
# Module server function
csvFile <- function(input, output, session) {
# The selected file, if any
userFile <- reactive({
# If no file is selected, don't do anything
validate(need(input$file, message = "please choose a csv.file from your computer or have a look at the example dataset"))
input$file
})
# The user's data, parsed into a data frame
dataframe <- reactive({
if(input$use_example == FALSE){
readr::read_csv(userFile()$datapath)
}else{
df_global_example
}
})
# We can run observers in here if we want to
# observe({
# msg <- sprintf("File %s was uploaded", userFile()$name)
# cat(msg, "\n")
# })
return(dataframe)
}