Skip to content

Commit

Permalink
Maybe we just need to simplify input a bit? #102
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMattG committed May 19, 2022
1 parent 74c30d1 commit 6549ba2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 47 deletions.
18 changes: 8 additions & 10 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,14 @@ shinyServer(

# if CSV data are supplied, add them to data_internal
observeEvent(input$sysmapdata_upload, {
data_internal$raw <- read.csv(
file = input$sysmapdata_upload$datapath,
header = input$header,
sep = input$sep,
dec = input$dec,
quote = input$quote,
fileEncoding = input$upload_encoding,
stringsAsFactors = F)
#data_internal$filtered <- data_internal$raw #instantiate filtered table with raw values
})
inFile <- input$sysmapdata_upload
extension <- tools::file_ext(inFile$name)
filepath <- inFile$datapath
data_internal$raw <- switch(extension,
csv = readr::read_csv2(filepath),
xls = readxl::read_xls(filepath),
xlsx = readxl::read_xlsx(filepath))
})

# if shapefile data are supplied, add them to data_internal
observeEvent(input$shape, {
Expand Down
43 changes: 6 additions & 37 deletions ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ body <- dashboardBody(
label = h4("Which Data to Use?"),
choices = list(
"Sample Data" = "sample",
"Upload from .csv format (spreadsheet)" = "user",
"Upload from .csv, .xlsx or .xls format (spreadsheet)" = "user",
"Upload from .shp format (shapefile)" = "shapefile"
),
selected = "user"
Expand All @@ -100,53 +100,22 @@ body <- dashboardBody(
fluidRow(
fileInput(
"sysmapdata_upload",
label = "Choose CSV File",
label = "Choose spreadsheet File",
multiple = FALSE,
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv"),
".csv",".xlsx",".xls"),
placeholder = "Systematic Map Data (100 MB Limit)"
)),

fluidRow(
column(12,
wellPanel(
h5(strong("CSV Properties")),
h5(strong("File Properties")),
# Input: Checkbox if file has header ----
checkboxInput("header", "Header row?", TRUE),

selectInput("upload_encoding",
label = "Select File Encoding",
choices = list("Default" = "",
"UTF-8",
"latin1",
"mac"),
selected = ""
),
# Input: Select separator ----
selectInput("sep",
"Field Separator",
choices = c(
",",
";",
Tab = "\t",
'|'
),
selected = ","
),
# Input: Select quotes ----
selectInput(
"quote",
"Quote Delimiter",
choices = c(
None = "",
'"',
"'"
),
selected = '"'
))))
)),
)
)))),
conditionalPanel(condition = "input.sample_or_real == 'shapefile'",
fluidRow(column(
12,
Expand Down

0 comments on commit 6549ba2

Please sign in to comment.