Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A couple thoughts #3

Open
wants to merge 1 commit into
base: joe/feature/filter
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ Version: 0.1.0
Author: Who wrote it
Maintainer: Who to complain to <[email protected]>
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
8 changes: 4 additions & 4 deletions R/controls.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcheng5 do we even need a group argument here? It could just derive from the sharedData's group property, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a different kind of group--it's a group in the dplyr sense. The select box lets you choose subsets of the rows to display; the group argument indicates how those subsets should be determined. I know this is confusing, we can pick different/better names.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the group argument indicates how those subsets should be determined

I don't follow. Would love an example.


df <- sharedData$data(
Expand All @@ -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_))

Copy link
Contributor Author

@cpsievert cpsievert May 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcheng5 I'm not sure I understand the intention here. Are you thinking there could/should be multiple groups for a given sharedData object?

if (is.factor(df$g) && allLevels) {
labels <- as.character(levels(df$g))
Expand All @@ -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),
Expand Down
4 changes: 4 additions & 0 deletions R/crosstalk.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down