Skip to content

Commit

Permalink
complete the merge, local checks pass
Browse files Browse the repository at this point in the history
  • Loading branch information
dajmcdon committed Oct 5, 2023
1 parent 0556b8c commit b8865c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions R/pivot_quantiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ nested_quantiles <- function(x) {
distributional:::dist_apply(x, .f = function(z) {
tibble::as_tibble(vec_data(z)) %>%
dplyr::mutate(dplyr::across(tidyselect::everything(), as.double)) %>%
list_of()
vctrs::list_of()
})
}

Expand Down Expand Up @@ -130,14 +130,14 @@ pivot_quantiles_wider <- function(.data, ...) {
.data <- .data %>%
tidyr::unnest(tidyselect::all_of(col)) %>%
tidyr::pivot_wider(
names_from = "tau", values_from = "q",
names_from = "quantile_levels", values_from = "values",
names_prefix = paste0(col, "_")
)
}
} else {
.data <- .data %>%
tidyr::unnest(tidyselect::all_of(cols)) %>%
tidyr::pivot_wider(names_from = "tau", values_from = "q")
tidyr::pivot_wider(names_from = "quantile_levels", values_from = "values")
}
.data
}
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-pivot_quantiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test_that("quantile pivotting longer behaves", {
tib$d1 <- d1
expect_length(pivot_quantiles_longer(tib, d1), 5L)
expect_identical(nrow(pivot_quantiles_longer(tib, d1)), 7L)
expect_identical(pivot_quantiles_longer(tib, d1)$q, as.double(c(1:3, 2:5)))
expect_identical(pivot_quantiles_longer(tib, d1)$values, as.double(c(1:3, 2:5)))

d1 <- c(dist_quantiles(1:3, 1:3 / 4), dist_quantiles(2:4, 2:4 / 4))
tib$d1 <- d1
Expand All @@ -62,7 +62,7 @@ test_that("quantile pivotting longer behaves", {
6L
)
expect_identical(
pivot_quantiles_longer(tib, d1, d3, .ignore_length_check = TRUE)$d1_q,
pivot_quantiles_longer(tib, d1, d3, .ignore_length_check = TRUE)$d1_values,
as.double(rep(c(1:3, 2:4), each = 4))
)
})

0 comments on commit b8865c4

Please sign in to comment.