Skip to content

Commit

Permalink
Move {tibble} to suggests (#5990)
Browse files Browse the repository at this point in the history
* don't use `tibble()` in code

* remove `tibble()` from examples/tests

* redocument

* add news bullet
  • Loading branch information
teunbrand committed Aug 26, 2024
1 parent bcb87fc commit 8bb9641
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 61 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ Imports:
rlang (>= 1.1.0),
scales (>= 1.3.0),
stats,
tibble,
vctrs (>= 0.6.0),
withr (>= 2.5.0)
Suggests:
Expand All @@ -67,6 +66,7 @@ Suggests:
sf (>= 0.7-3),
svglite (>= 2.1.2),
testthat (>= 3.1.5),
tibble,
vdiffr (>= 1.0.6),
xml2
Enhances:
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,6 @@ importFrom(grid,unit)
importFrom(lifecycle,deprecated)
importFrom(scales,alpha)
importFrom(stats,setNames)
importFrom(tibble,tibble)
importFrom(utils,.DollarNames)
importFrom(utils,head)
importFrom(utils,tail)
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
(@teunbrand, #4584).
* `theme_classic()` now has black ticks and text instead of dark gray. In
addition, `theme_classic()`'s axis line end is `"square"` (@teunbrand, #5978).
* {tibble} is now suggested instead of imported (@teunbrand, #5986)

# ggplot2 3.5.1

Expand Down
2 changes: 1 addition & 1 deletion R/facet-.R
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ is_facets <- function(x) {
# but that seems like a reasonable tradeoff.
eval_facets <- function(facets, data, possible_columns = NULL) {
vars <- compact(lapply(facets, eval_facet, data, possible_columns = possible_columns))
data_frame0(tibble::as_tibble(vars))
data_frame0(!!!vars)
}
eval_facet <- function(facet, data, possible_columns = NULL) {
# Treat the case when `facet` is a quosure of a symbol specifically
Expand Down
12 changes: 5 additions & 7 deletions R/position-stack.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,12 @@
#'
#' # Negative values -----------------------------------------------------------
#'
#' df <- tibble::tribble(
#' ~x, ~y, ~grp,
#' "a", 1, "x",
#' "a", 2, "y",
#' "b", 1, "x",
#' "b", 3, "y",
#' "b", -1, "y"
#' df <- data.frame(
#' x = rep(c("a", "b"), 2:3),
#' y = c(1, 2, 1, 3, -1),
#' grp = c("x", "y", "x", "y", "y")
#' )
#'
#' ggplot(data = df, aes(x, y, group = grp)) +
#' geom_col(aes(fill = grp), position = position_stack(reverse = TRUE)) +
#' geom_hline(yintercept = 0)
Expand Down
4 changes: 2 additions & 2 deletions R/summarise-plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ summarise_layout <- function(p) {
l <- p$layout

layout <- l$layout
layout <- tibble(
layout <- data_frame0(
panel = l$layout$PANEL,
row = l$layout$ROW,
col = l$layout$COL
Expand Down Expand Up @@ -134,7 +134,7 @@ summarise_layers <- function(p) {

# This currently only returns the mappings, but in the future, other
# information could be added.
tibble(
data_frame0(
mapping = layer_mappings
)
}
4 changes: 0 additions & 4 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,6 @@ seq_asc <- function(to, from) {
}
}

# Needed to trigger package loading
#' @importFrom tibble tibble
NULL

# Wrapping vctrs data_frame constructor with no name repair
data_frame0 <- function(...) data_frame(..., .name_repair = "minimal")

Expand Down
12 changes: 5 additions & 7 deletions man/position_stack.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-geom-quantile.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test_that("geom_quantile matches quantile regression", {

set.seed(6531)
x <- rnorm(10)
df <- tibble::tibble(
df <- data_frame0(
x = x,
y = x^2 + 0.5 * rnorm(10)
)
Expand Down
9 changes: 4 additions & 5 deletions tests/testthat/test-geom-tile.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ test_that("accepts width and height aesthetics", {
geom_tile(fill = NA, colour = "black", linewidth = 1)
out <- get_layer_data(p)

boundary <- as.data.frame(tibble::tribble(
~xmin, ~xmax, ~ymin, ~ymax,
-1, 1, -1, 1,
-2, 2, -2, 2
))
boundary <- data_frame0(
xmin = c(-1, -2), xmax = c(1, 2),
ymin = c(-1, -2), ymax = c(1, 2)
)
expect_equal(out[c("xmin", "xmax", "ymin", "ymax")], boundary)
})

Expand Down
7 changes: 3 additions & 4 deletions tests/testthat/test-scale-discrete.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Missing values ----------------------------------------------------------

df <- tibble::tibble(
df <- data_frame0(
x1 = c("a", "b", NA),
x2 = factor(x1),
x3 = addNA(x2),

x2 = factor(c("a", "b", NA)),
x3 = factor(c("a", "b", NA), levels = c("a", "b", NA), exclude = NULL),
y = 1:3
)

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-sec-axis.R
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ test_that("sec axis works with tidy eval", {
g
}

t <- tibble(x = letters, y = seq(10, 260, 10), z = 1:26)
t <- data_frame0(x = letters, y = seq(10, 260, 10), z = 1:26)

p <- f(t, x, y, z)

Expand Down
39 changes: 12 additions & 27 deletions tests/testthat/test-stat-align.R
Original file line number Diff line number Diff line change
@@ -1,44 +1,29 @@
test_that("standard alignment works", {
df <- tibble::tribble(
~g, ~x, ~y,
"a", 1, 2,
"a", 3, 5,
"a", 5, 1,
"b", 2, 3,
"b", 4, 6,
"b", 6, 7
df <- data_frame0(
g = rep(c("a", "b"), each = 3L),
x = c(1, 3, 5, 2, 4, 6),
y = c(2, 5, 1, 3, 6, 7)
)
p <- ggplot(df, aes(x, y, fill = g)) + geom_area(color = "black")
expect_doppelganger("align two areas", p)
})

test_that("alignment with cliffs works", {
df <- tibble::tribble(
~g, ~x, ~y,
"a", 1, 2,
"a", 3, 5,
"a", 5, 1,
"b", 2, 3,
"b", 4, 3,
"b", 4, 6,
"b", 6, 7
df <- data_frame0(
g = rep(c("a", "b"), 3:4),
x = c(1, 3, 5, 2, 4, 4, 6),
y = c(2, 5, 1, 3, 3, 6, 7)
)

p <- ggplot(df, aes(x, y, fill = g)) + geom_area(color = "black")
expect_doppelganger("align two areas with cliff", p)
})

test_that("alignment with negative and positive values works", {
df <- tibble::tribble(
~g, ~x, ~y,
"a", 1, 1,
"a", 2, 4,
"a", 3, -4,
"a", 8, 0,
"b", 2, 4,
"b", 6, -4
df <- data_frame0(
g = rep(c("a", "b"), c(4L, 2L)),
x = c(1, 2, 3, 8, 2, 6),
y = c(1, 4, -4, 0, 4, -4)
)

p <- ggplot(df, aes(x, y, fill = g)) + geom_area(color = "black")
expect_doppelganger("align two areas with pos/neg y", p)
})
Expand Down

0 comments on commit 8bb9641

Please sign in to comment.