Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adorn_percentages("col") after adorn_totals("col") does not work #525

Closed
arhot opened this issue Feb 2, 2023 · 3 comments
Closed

adorn_percentages("col") after adorn_totals("col") does not work #525

arhot opened this issue Feb 2, 2023 · 3 comments

Comments

@arhot
Copy link

arhot commented Feb 2, 2023

Previously working code to get both per-column % and total % is broken, including the example from here https://sfirke.github.io/janitor/articles/tabyls.html

set.seed(1)
raw_data <- data.frame(sex = rep(c("m", "f"), 3000),
                       age = round(runif(3000, 1, 102), 0))
raw_data$agegroup = cut(raw_data$age, quantile(raw_data$age, c(0, 1/3, 2/3, 1)))

comparison <- raw_data %>%
  tabyl(agegroup, sex, show_missing_levels = F) %>%
  adorn_totals(c("row", "col")) %>%
  adorn_percentages("col") %>%
  adorn_pct_formatting(digits = 1)

Results in erroring out with "Error in FUN(X[[i]], ...) : only defined on a data frame with all numeric-alike variables"
Not adding a total column before adorning percentages fixes it.

It is a call to a non-janitor function that fails, so it could plausibly be a package issue (setdiff()?) so I can share session info if need be, but I figured I'd let you know and see if you can reproduce it.

@sfirke
Copy link
Owner

sfirke commented Feb 2, 2023 via email

@arhot
Copy link
Author

arhot commented Feb 2, 2023

Great, thanks, sorry about the spam! I looked at open issues but didn't think it would be in process, looking forward to the new version!

@sfirke
Copy link
Owner

sfirke commented Feb 2, 2023

Whew janitor 2.2.0 is on CRAN now. Try installing it like normal and see if this resolves 😁 Thanks for reporting!

@sfirke sfirke closed this as completed Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants