diff --git a/DESCRIPTION b/DESCRIPTION index 454d531..d771815 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -5,8 +5,12 @@ Version: 0.1.0 Author: Who wrote it Maintainer: Who to complain to Description: More about what it does (maybe more than one line) -License: What license is it under? -LazyData: MIT +License: GPL-3 +LazyData: true Imports: - htmltools + htmltools, + htmlwidgets, + shiny +Suggests: + rmarkdown RoxygenNote: 5.0.1 diff --git a/R/controls.R b/R/controls.R index 38c1c6f..4d1fac0 100644 --- a/R/controls.R +++ b/R/controls.R @@ -30,7 +30,7 @@ jqueryLib <- function() { } #' @export -filter_select <- function(id, label, sharedData, group, allLevels = FALSE, +filter_select <- function(id, label, sharedData, group = "default", allLevels = FALSE, multiple = TRUE) { df <- sharedData$data( @@ -39,9 +39,8 @@ filter_select <- function(id, label, sharedData, group, allLevels = FALSE, withKey = TRUE ) - df <- df %>% - dplyr::group_by_(group = group) %>% - dplyr::summarise(key = list(key_)) + # TODO: should this package really depend on dplyr? + df <- dplyr::summarise(dplyr::group_by(df, g = group), key = list(key_)) if (is.factor(df$g) && allLevels) { labels <- as.character(levels(df$g)) @@ -57,6 +56,7 @@ filter_select <- function(id, label, sharedData, group, allLevels = FALSE, group = sharedData$groupName() ) + # TODO: should this be spitting out an HTMLwidget? attachDependencies( tags$div(class = "form-group", tags$label(class = "control-label", `for` = id, label), diff --git a/R/crosstalk.R b/R/crosstalk.R index 7deaa57..362def7 100644 --- a/R/crosstalk.R +++ b/R/crosstalk.R @@ -114,6 +114,9 @@ SharedData <- R6Class( ), public = list( initialize = function(data, key, interactionMode = "select", group = "default") { + if (!missing(key) && length(key) == 1 && !key %in% names(data)) { + warning("key argument not found in names of data", call. = FALSE) + } private$.data <- data private$.key <- key private$.filterCV <- ClientValue$new("filter", group) @@ -158,6 +161,7 @@ SharedData <- R6Class( df[[private$.key]] }, data = function(withSelection = FALSE, withFilter = TRUE, withKey = FALSE) { + df <- if (shiny::is.reactive(private$.data)) { private$.data() } else {