Skip to content

Commit 142c29f

Browse files
authored
Merge pull request #109 from DavisVaughan/fix/vctrs-compat
Remove `dim` attribute before calling `bind_rows()`
2 parents b2264f2 + 70a15b0 commit 142c29f

File tree

5 files changed

+32
-14
lines changed

5 files changed

+32
-14
lines changed

R/geom_connector.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ GeomConnector <- ggproto(
194194
) |>
195195
unclass() |>
196196
as.list() |>
197+
undim() |>
197198
dplyr::bind_rows()
198199
data <- flip_data(data, flipped_aes)
199200
GeomPath$draw_panel(
@@ -237,3 +238,20 @@ connect_points <- function(data, width = 0.9, continuous = FALSE) {
237238
dplyr::arrange(.data[["..rank.."]], .data[["..order.."]]) |>
238239
dplyr::select(-dplyr::all_of(c("..rank..", "..order..")))
239240
}
241+
242+
undim <- function(x) {
243+
dim <- dim(x)
244+
245+
if (is.null(dim)) {
246+
return(x)
247+
}
248+
249+
dim(x) <- NULL
250+
251+
if (length(dim) == 1L && !is.null(rownames(x))) {
252+
# Preserve names of 1D arrays
253+
names(x) <- rownames(x)
254+
}
255+
256+
x
257+
}

R/weighted_quantile.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,5 @@ weighted.quantile <- function(x, w, probs = seq(0, 1, 0.25),
104104
format(100 * probs, trim = TRUE),
105105
"%"
106106
)
107-
return(result)
107+
result
108108
}

tests/testthat/test-ggcoef_model.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test_that("ggcoef_model()", {
2727
# custom variable labels
2828
# you can use to define variable labels before computing model
2929
if (requireNamespace("labelled")) {
30-
tips_labelled <- tips %>%
30+
tips_labelled <- tips |>
3131
labelled::set_variable_labels(
3232
day = "Day of the week",
3333
time = "Lunch or Dinner",
@@ -273,8 +273,8 @@ test_that("ggcoef_model() works with tieders not returning p-values", {
273273

274274
mod <- lm(Sepal.Width ~ Species, iris)
275275
my_tidier <- function(x, ...) {
276-
x %>%
277-
broom::tidy(...) %>%
276+
x |>
277+
broom::tidy(...) |>
278278
dplyr::select(-dplyr::all_of("p.value"))
279279
}
280280
vdiffr::expect_doppelganger(
@@ -346,7 +346,7 @@ test_that("ggcoef_model() works with pairwise contratst", {
346346
test_that("tidy_args is supported", {
347347
mod <- lm(Sepal.Length ~ Sepal.Width, data = iris)
348348
custom <- function(x, force = 1, ...) {
349-
broom::tidy(x, ...) %>%
349+
broom::tidy(x, ...) |>
350350
dplyr::mutate(estimate = force)
351351
}
352352
res <- ggcoef_model(

tests/testthat/test-gglikert.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test_that("gglikert()", {
2020
q4 = sample(likert_levels, 150, replace = TRUE, prob = 1:5),
2121
q5 = sample(c(likert_levels, NA), 150, replace = TRUE),
2222
q6 = sample(likert_levels, 150, replace = TRUE, prob = c(1, 0, 1, 1, 0))
23-
) %>%
23+
) |>
2424
dplyr::mutate(dplyr::across(
2525
dplyr::everything(),
2626
~ factor(.x, levels = likert_levels)
@@ -45,7 +45,7 @@ test_that("gglikert()", {
4545
likert_levels_dk, 150,
4646
replace = TRUE, prob = c(1, 0, 1, 1, 0, 1)
4747
)
48-
) %>%
48+
) |>
4949
dplyr::mutate(dplyr::across(
5050
dplyr::everything(),
5151
~ factor(.x, levels = likert_levels_dk)
@@ -159,12 +159,12 @@ test_that("gglikert()", {
159159

160160
vdiffr::expect_doppelganger(
161161
"gglikert() variable labels and y_label_wrap",
162-
df %>%
162+
df |>
163163
labelled::set_variable_labels(
164164
q1 = "first question",
165165
q2 = "second question",
166166
q3 = "third question with a very very very veru very very long label"
167-
) %>%
167+
) |>
168168
gglikert(
169169
variable_labels = c(
170170
q2 = "question 2",

tests/testthat/test-stat_cross.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ test_that("stat_cross()", {
5757
})
5858

5959
test_that("phi coefficients", {
60-
res <- Titanic %>%
61-
as.data.frame() %>%
62-
xtabs(Freq ~ Sex + Class, data = .) %>%
63-
chisq.test() %>%
64-
augment_chisq_add_phi() %>%
60+
res <- Titanic |>
61+
as.data.frame() |>
62+
xtabs(Freq ~ Sex + Class, data = _) |>
63+
chisq.test() |>
64+
augment_chisq_add_phi() |>
6565
dplyr::mutate(.phi = round(.data$.phi, digits = 3))
6666
expect_equal(
6767
res$.phi,

0 commit comments

Comments
 (0)