Skip to content
Snippets Groups Projects
Commit 2582f61c authored by Theodore Vanrenterghem's avatar Theodore Vanrenterghem
Browse files

Merge branch 'dev'

parents cd59e413 e89193a5
No related branches found
Tags v0.1.6
No related merge requests found
Pipeline #124020 passed
......@@ -2,7 +2,7 @@
#'
#' @description Check the raw data.frame according to inputs
#'
#' @param dta=NULL,inputs=NULL
#' @param dta=NULL,inputs=NULL,show_message_repeated_rows=FALSE
#' `dta` data.frame
#' `inputs` list of inputs from upload table:
#' - `input$dataType`
......@@ -14,16 +14,16 @@
#' and warnings with indication to get a better results
#'
#' @noRd
check_data_inputs <- function(dta = NULL, inputs = NULL) {
check_data_inputs <- function(dta = NULL, inputs = NULL, show_message_repeated_rows = FALSE) {
## Check for all cases
# Table are too thin could be a separator problem
if (dim(dta)[2] <= 1) {
if (ncol(dta) <= 1) {
warning("Low number of columns: Try to change separator")
} else { # if table are thicker
# Prevent miss-comprehension: if set rows as name and the first column has
# repetition it would give an error and stop the app. The real correction is
# in "mod_tab_upload.R" but here is a message that tell what's happening to the user
if (inputs$headerrow & any(duplicated(dta[[1]])) & is.character(dta[[1]])) {
if (inputs$headerrow & show_message_repeated_rows) {
message("Repeated values in the 1st column: cannot be set as row names")
}
## Check in case of a adjacency matrix
......
......@@ -58,7 +58,12 @@ mod_help_to_import_server <- function(id, rawData = NULL, sbmData = NULL, input_
if (!is.null(rawData) & !is.null(input_upload) && input_upload$whichData == "importData") {
warns <- list()
mess <- list()
withCallingHandlers(check_data_inputs(dta = rawData(), inputs = input_upload),
withCallingHandlers(
check_data_inputs(
dta = rawData(),
inputs = input_upload,
show_message_repeated_rows = session$userData$vars$show_message_repeated_rows
),
warning = function(w) {
warns <<- c(warns, list(w))
},
......
......@@ -194,6 +194,7 @@ mod_tab_upload_server <- function(id, r, parent_session) {
ns <- session$ns
## will be used in other modules inside conditionnal panels that should only be shown when the sbm has been run
# reset when loading a new matrix
session$userData$vars$show_message_repeated_rows <- FALSE
output$sbmRan <- renderText({
if (session$userData$vars$sbm$runSbm != 0) {
"YES"
......@@ -265,6 +266,7 @@ mod_tab_upload_server <- function(id, r, parent_session) {
sep(), dec(), input$headerrow,
input$headercol
), {
session$userData$vars$show_message_repeated_rows <- FALSE
if (input$whichData == "importData") {
validate(
need(input$mainDataFile$datapath, "")
......@@ -276,8 +278,12 @@ mod_tab_upload_server <- function(id, r, parent_session) {
row.names = 1, header = input$headercol,
check.names = FALSE
)
} else {
data <- read.table(file = input$mainDataFile$datapath, sep = sep(), header = input$headercol,check.names = FALSE)
if(input$headerrow){
session$userData$vars$show_message_repeated_rows <- TRUE
}
}
} else {
validate(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment