-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Reprex:
dat <- data.frame(
grp = c(1, 2, 1, 2),
num = c(1, 2, 3, 4),
cat = factor(c("a", "a", "b", "b"))
)
cb <- cb_create(dat)
cb_summarize_numeric(cb, group_by = grp)
# Error in `dplyr::summarize()`:
# ℹ In argument: `dplyr::across(.cols = c("grp", "num"), .fns = .fns, .names = "{.col}__SEP__{.fn}")`.
# Caused by error in `across()`:
# ! Can't select columns that don't exist.
# ✖ Column `grp` doesn't exist.Works fine for cb_summarize_categorical():
cb_summarize_categorical(cb, group_by = grp)
# # A tibble: 4 × 6
# grp name value n pct_of_all pct_of_valid
# <fct> <chr> <chr> <int> <dbl> <dbl>
# 1 1 cat a 1 0.5 0.5
# 2 1 cat b 1 0.5 0.5
# 3 2 cat a 1 0.5 0.5
# 4 2 cat b 1 0.5 0.5And works for both if grp isn't numeric:
cb2 <- dat |>
transform(grp = factor(grp)) |>
cb_create()
cb_summarize_numeric(cb2, group_by = grp)
# # A tibble: 2 × 13
# grp name valid_n valid_pct mean SD median MAD min max range skew
# <fct> <chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
# 1 1 num 2 1 2 1.41 2 1.48 1 3 2 NA
# 2 2 num 2 1 3 1.41 3 1.48 2 4 2 NA
# # ℹ 1 more variable: kurt <dbl>
cb_summarize_categorical(cb2, group_by = grp)
# # A tibble: 4 × 6
# grp name value n pct_of_all pct_of_valid
# <fct> <chr> <chr> <int> <dbl> <dbl>
# 1 1 cat a 1 0.5 0.5
# 2 1 cat b 1 0.5 0.5
# 3 2 cat a 1 0.5 0.5
# 4 2 cat b 1 0.5 0.5Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels