Skip to content

Let check_nondata_cols allow Vector class (#3835) #3837

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

Merged
merged 5 commits into from
Mar 8, 2020
Merged
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
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

* Added an `outside` option to `annotation_logticks()` that places tick marks
outside of the plot bounds. (#3783, @kbodwin)

* Data columns can now contain `Vector` S4 objects, which are widely used in the
Bioconductor project. (@teunbrand, #3837)

# ggplot2 3.3.0

Expand Down
15 changes: 10 additions & 5 deletions R/utilities.r
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,16 @@ is.discrete <- function(x) {
is.factor(x) || is.character(x) || is.logical(x)
}

# This function checks that all columns of a dataframe `x` are data and
# returns the names of any columns that are not.
# We define "data" as atomic types or lists, not functions or otherwise
# This function checks that all columns of a dataframe `x` are data and returns
# the names of any columns that are not.
# We define "data" as atomic types or lists, not functions or otherwise.
# The `inherits(x, "Vector")` check is for checking S4 classes from Bioconductor
# and wether they can be expected to follow behavior typical of vectors. See
# also #3835
check_nondata_cols <- function(x) {
idx <- (vapply(x, function(x) is.null(x) || rlang::is_vector(x), logical(1)))
idx <- (vapply(x, function(x) {
is.null(x) || rlang::is_vector(x) || inherits(x, "Vector")
}, logical(1)))
names(x)[which(!idx)]
}

Expand Down Expand Up @@ -379,7 +384,7 @@ NULL
# Check inputs with tibble but allow column vectors (see #2609 and #2374)
as_gg_data_frame <- function(x) {
x <- lapply(x, validate_column_vec)
new_data_frame(tibble::as_tibble(x))
new_data_frame(x)
}
validate_column_vec <- function(x) {
if (is_column_vec(x)) {
Expand Down