Skip to content

Commit db58364

Browse files
authored
Let check_nondata_cols allow Vector class (#3835) (#3837)
* Let check_nondata_cols allow Vector class * Remove as_tibble from as_gg_data_frame * Add NEWS.md bullet * Rephrase news bullet
1 parent 8dde91a commit db58364

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
* Added an `outside` option to `annotation_logticks()` that places tick marks
1010
outside of the plot bounds. (#3783, @kbodwin)
11+
12+
* Data columns can now contain `Vector` S4 objects, which are widely used in the
13+
Bioconductor project. (@teunbrand, #3837)
1114

1215
# ggplot2 3.3.0
1316

R/utilities.r

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,16 @@ is.discrete <- function(x) {
285285
is.factor(x) || is.character(x) || is.logical(x)
286286
}
287287

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

@@ -379,7 +384,7 @@ NULL
379384
# Check inputs with tibble but allow column vectors (see #2609 and #2374)
380385
as_gg_data_frame <- function(x) {
381386
x <- lapply(x, validate_column_vec)
382-
new_data_frame(tibble::as_tibble(x))
387+
new_data_frame(x)
383388
}
384389
validate_column_vec <- function(x) {
385390
if (is_column_vec(x)) {

0 commit comments

Comments
 (0)