Commit c1c9f369 authored by Jean-Karim Heriche's avatar Jean-Karim Heriche

Try to detect use of wrong field separator when uploading data file.

parent 435e9544
......@@ -155,7 +155,7 @@ input_data_server <- function(input, output, session) {
Output_variable("groupsColumn", "groupLabels", "Select column containing group labels", FALSE, list(maxItems = 1))
## Select columns containing ROI coordinates
Select_colums_coordinates <- function( coor, name, id, label){
Select_colums_coordinates <- function(coor, name, id, label){
output[[coor]] <- renderUI({
colNames <- names(rv$data)
## Try to infer from name and set as default
......@@ -194,7 +194,7 @@ input_data_server <- function(input, output, session) {
})
## Select column containing image file names as paths relative to image dir
Select_colums_image_file_names <- function( type, grepl_name, id, label_image){
Select_colums_image_file_names <- function(type, grepl_name, id, label_image){
output[[type]] <- renderUI({
colNames <- names(rv$data)
selection <- NULL
......@@ -245,10 +245,10 @@ input_data_server <- function(input, output, session) {
## Save current choices to a file
output$saveConfigFile <- downloadHandler(
filename = function() {
filename = function(){
data.file <- tools::file_path_sans_ext(basename(input$datafile$name))
paste0("IDE-saved_input_choices-", data.file, "-", Sys.Date(), ".rds") },
content = function(file) {
content = function(file){
## Collect current choices
rv$inputChoices[["imgRoot"]] <- parseDirPath(roots, input$imgRoot)
settings <- list("selectedVar" = input$selectedVar, "colsOnHover" = input$colsOnHover,
......@@ -285,7 +285,7 @@ input_data_server <- function(input, output, session) {
})
## Populate fields in UI
SelectizeInput<-function(id){
SelectizeInput <- function(id){
updateSelectizeInput(session = session, inputId = id, selected = rv$inputChoices[[id]])
}
......@@ -295,7 +295,7 @@ input_data_server <- function(input, output, session) {
Check_extension_file()
})
Check_extension_file <-function(){
Check_extension_file <- function(){
# This uses the assertthat package
if (see_if(has_extension(input$datafile$datapath, 'csv')) == TRUE
| see_if(has_extension(input$datafile$datapath, 'txt')) == TRUE
......@@ -308,7 +308,7 @@ input_data_server <- function(input, output, session) {
}
## Read uploaded data file
Upload_data_file <- function (){
Upload_data_file <- function(){
observeEvent(input$datafile, {
if (is.null(input$datafile)) return(NULL)
......@@ -325,6 +325,12 @@ input_data_server <- function(input, output, session) {
sep = input$sep,
quote = input$quote,
stringsAsFactors = FALSE)
## Try and detect use of wrong separator
if(ncol(rv$data)<2) {
showNotification("Possible use of wrong field separator detected. Please select the correct field separator before uploading the file again.",
type = "warning",
duration = NULL)
}
rv$data[,"id"] <- c(1:nrow(rv$data)) # Used to uniquely identify data points
rv$data[,"idx"] <- sample(c(1:nrow(rv$data))) # Used to reorder data points
# These don't need to be visible to the user
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment