From eafd7c56aa8d14419638ddc952e2f64abc5aea2d Mon Sep 17 00:00:00 2001 From: pvictor Date: Mon, 4 Mar 2019 22:49:43 +0100 Subject: [PATCH] drop list columns --- DESCRIPTION | 2 +- R/esquisser.R | 3 +++ R/esquisserServer.R | 4 ++-- R/get_data.R | 3 +++ R/utils.R | 5 ++++- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index fd65d6f6..643778b9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: esquisse Type: Package Title: Explore and Visualize Your Data Interactively -Version: 0.1.7.940 +Version: 0.1.7.950 Authors@R: c(person("Fanny", "Meyer", email = "fanny.meyer@dreamrs.fr", role = c("aut")), person("Victor", "Perrier", email = "victor.perrier@dreamrs.fr", role = c("aut", "cre")), person("Ian", "Carroll", comment = "Facets support", role = "ctb")) diff --git a/R/esquisser.R b/R/esquisser.R index e35b9097..276d36dd 100644 --- a/R/esquisser.R +++ b/R/esquisser.R @@ -35,6 +35,9 @@ esquisser <- function(data = NULL, options("esquisse.coerceVars" = coerceVars) res_data <- get_data(data, name = deparse(substitute(data))) + if (!is.null(res_data$esquisse_data)) { + res_data$esquisse_data <- dropListColumns(res_data$esquisse_data) + } rv <- reactiveValues( data = res_data$esquisse_data, name = res_data$esquisse_data_name diff --git a/R/esquisserServer.R b/R/esquisserServer.R index d4213781..0769c37a 100644 --- a/R/esquisserServer.R +++ b/R/esquisserServer.R @@ -124,7 +124,7 @@ esquisserServer <- function(input, output, session, data = NULL, dataModule = c( # print(paste("EXECUTED", i)) data <- dataChart$data - if (!is.null(paramsChart$index) && is.logical(paramsChart$index)) { + if (!is.null(paramsChart$index) && is.logical(paramsChart$index) & length(paramsChart$index) > 0) { data <- data[paramsChart$index, , drop = FALSE] } @@ -209,7 +209,7 @@ esquisserServer <- function(input, output, session, data = NULL, dataModule = c( }, ignoreInit = TRUE) observeEvent(list(dataChart$data, paramsChart$index), { data <- dataChart$data - if (!is.null(paramsChart$index) && is.logical(paramsChart$index)) { + if (!is.null(paramsChart$index) && is.logical(paramsChart$index) & length(paramsChart$index) > 0) { data <- data[paramsChart$index, , drop = FALSE] } output_module$data <- data diff --git a/R/get_data.R b/R/get_data.R index 17c9f845..224f890e 100644 --- a/R/get_data.R +++ b/R/get_data.R @@ -42,6 +42,9 @@ get_data <- function(data = NULL, name = NULL) { } # esquisse_data_name <- gsub("\\[.*", "", esquisse_data_name) + } else { + esquisse_data <- NULL + esquisse_data_name <- "" } } else { if (rstudioapi::isAvailable()) { diff --git a/R/utils.R b/R/utils.R index 6de1bc6f..e292c5fb 100644 --- a/R/utils.R +++ b/R/utils.R @@ -281,5 +281,8 @@ capitalize <- function(x) { } - +dropListColumns <- function(x) { + type_col <- vapply(X = x, FUN = typeof, FUN.VALUE = character(1), USE.NAMES = FALSE) + x[, type_col != "list", drop = FALSE] +}