Skip to content

Commit f5aeb67

Browse files
authored
Fix tidyverse#3014 force col_names (tidyverse#3015)
* Fix tidyverse#3014 force col_names to make sure it is calculated before x is converted to a list * Add unit test
1 parent 6057d7f commit f5aeb67

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

R/performance.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ data.frame <- function(...) {
2727
}
2828

2929
mat_2_df <- function(x, col_names = colnames(x), .check = FALSE) {
30+
force(col_names)
3031
x <- lapply(seq_len(ncol(x)), function(i) x[, i])
3132
if (!is.null(col_names)) names(x) <- col_names
3233
new_data_frame(x)

tests/testthat/test-stat-ellipsis.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
context("stat_ellipsis")
2+
3+
test_that("stat_ellipsis returns correct data format", {
4+
n_seg <- 40
5+
d <- data_frame(x = c(1, 1, 4, 4, 4, 3, 3, 1), y = c(1:4, 1:4), id = rep(1:2, each = 4))
6+
p <- ggplot(d, aes(x = x, y = y, group = id)) +
7+
geom_point() +
8+
stat_ellipse(segments = n_seg)
9+
out <- layer_data(p, 2)
10+
expect_equal(nrow(out), (n_seg + 1) * 2)
11+
expect_equal(unique(out$group), c(1, 2))
12+
})

0 commit comments

Comments
 (0)