From 5d295a0fde9b201b568b3562031213c5dc7110b1 Mon Sep 17 00:00:00 2001 From: Claus Wilke Date: Sun, 10 Jun 2018 17:39:36 -0500 Subject: [PATCH 1/3] Don't change data order in facet_grid() or facet_wrap(). Enables data vectors to be provided via aes() or as parameters. --- R/facet-grid-.r | 2 +- R/facet-wrap.r | 2 +- tests/testthat/test-facet-map.r | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/R/facet-grid-.r b/R/facet-grid-.r index 435a98a7f4..c36d1fd20a 100644 --- a/R/facet-grid-.r +++ b/R/facet-grid-.r @@ -288,7 +288,7 @@ FacetGrid <- ggproto("FacetGrid", Facet, data$PANEL <- layout$PANEL[match(keys$x, keys$y)] } - data[order(data$PANEL), , drop = FALSE] + data }, draw_panels = function(panels, layout, x_scales, y_scales, ranges, coord, data, theme, params) { if ((params$free$x || params$free$y) && !coord$is_free()) { diff --git a/R/facet-wrap.r b/R/facet-wrap.r index 281ae1f2f7..ad7ba3ca23 100644 --- a/R/facet-wrap.r +++ b/R/facet-wrap.r @@ -199,7 +199,7 @@ FacetWrap <- ggproto("FacetWrap", Facet, keys <- plyr::join.keys(facet_vals, layout, by = names(vars)) data$PANEL <- layout$PANEL[match(keys$x, keys$y)] - data[order(data$PANEL), ] + data }, draw_panels = function(panels, layout, x_scales, y_scales, ranges, coord, data, theme, params) { if ((params$free$x || params$free$y) && !coord$is_free()) { diff --git a/tests/testthat/test-facet-map.r b/tests/testthat/test-facet-map.r index 5a7f1caa27..045b1c4781 100644 --- a/tests/testthat/test-facet-map.r +++ b/tests/testthat/test-facet-map.r @@ -31,7 +31,7 @@ test_that("grid: missing facet columns are duplicated", { loc_a <- panel_map_one(facet, df_a, plot_data = df) expect_equal(nrow(loc_a), 4) - expect_equal(loc_a$PANEL, factor(1:4)) + expect_equal(loc_a$PANEL, factor(c(1, 3, 2, 4))) loc_b <- panel_map_one(facet, df_b, plot_data = df) expect_equal(nrow(loc_b), 4) @@ -47,8 +47,8 @@ test_that("wrap: missing facet columns are duplicated", { loc_a <- panel_map_one(facet, df_a, plot_data = df) expect_equal(nrow(loc_a), 4) - expect_equal(loc_a$PANEL, factor(1:4)) - expect_equal(loc_a$a, c(1, 1, 2, 2)) + expect_equal(loc_a$PANEL, factor(c(1, 3, 2, 4))) + expect_equal(loc_a$a, c(1, 2, 1, 2)) loc_b <- panel_map_one(facet, df_b, plot_data = df) expect_equal(nrow(loc_b), 4) From 6460e563c672708996e876e650eb6098a04068c4 Mon Sep 17 00:00:00 2001 From: Claus Wilke Date: Sun, 8 Jul 2018 22:24:44 -0500 Subject: [PATCH 2/3] add news item --- NEWS.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index c0416accec..484052ca0b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,9 +1,13 @@ # ggplot2 3.0.0.9000 -* `geom_hex()` now understands the `size` and `linetype` aesthetics - (@mikmart, #2488). - -# ggplot2 3.0.0 +## Minor bug fixes and improvements + +* `geom_hex()` now understands the `size` and `linetype` aesthetics + (@mikmart, #2488). + +* Data is no longer internally reordered when faceting. This makes it safer to + feed data columns into `aes()` or into parameters of geoms or stats. However, + doing so remains discouraged (@clauswilke). ## Breaking changes From d99a02610326776bca2dd4075037e0275b7b2510 Mon Sep 17 00:00:00 2001 From: Claus Wilke Date: Tue, 10 Jul 2018 01:12:41 -0500 Subject: [PATCH 3/3] remove subheading in NEWS.md --- NEWS.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 484052ca0b..19cdf00f9b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,14 +1,15 @@ # ggplot2 3.0.0.9000 -## Minor bug fixes and improvements - * `geom_hex()` now understands the `size` and `linetype` aesthetics (@mikmart, #2488). - + * Data is no longer internally reordered when faceting. This makes it safer to feed data columns into `aes()` or into parameters of geoms or stats. However, doing so remains discouraged (@clauswilke). + +# ggplot2 3.0.0 + ## Breaking changes * ggplot2 now supports/uses tidy evaluation (as described below). This is a