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

tabyl: adorn_totals() name argument does not work on 3 way #306

Closed
jzadra opened this issue Jul 10, 2019 · 2 comments · Fixed by #307
Closed

tabyl: adorn_totals() name argument does not work on 3 way #306

jzadra opened this issue Jul 10, 2019 · 2 comments · Fixed by #307
Assignees
Labels

Comments

@jzadra
Copy link
Contributor

jzadra commented Jul 10, 2019

The adorn_totals() name argument is ignored when used on a 3 way tabyl:

suppressPackageStartupMessages(require(janitor))
mtcars %>% 
  tabyl(gear, cyl, vs) %>% 
  adorn_totals(name = "NAME DOES NOT WORK ON 3-WAY")
#> $`0`
#>   gear 4 6  8
#>      3 0 0 12
#>      4 0 2  0
#>      5 1 1  2
#>  Total 1 3 14
#> 
#> $`1`
#>   gear  4 6 8
#>      3  1 2 0
#>      4  8 2 0
#>      5  1 0 0
#>  Total 10 4 0

mtcars %>% 
  tabyl(gear, cyl) %>% 
  adorn_totals(name = "TOTALS NAME WORKS ON 2-WAY")
#>                        gear  4 6  8
#>                           3  1 2 12
#>                           4  8 4  0
#>                           5  2 1  2
#>  TOTALS NAME WORKS ON 2-WAY 11 7 14

Created on 2019-07-10 by the reprex package (v0.2.1)

@sfirke
Copy link
Owner

sfirke commented Jul 10, 2019

Thanks for reporting. Looks like I just need to add the name argument to the recursive call on line 22 here: https://github.com/sfirke/janitor/blob/master/R/adorn_totals.R#L22

I'll add that plus a unit test.

@jzadra
Copy link
Contributor Author

jzadra commented Jul 11, 2019

Awesome, thank you! And so fast :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants