library(janitor) mtcars %>% tabyl(cyl, gear) %>% adorn_totals("row") cyl 3 4 5 4 1 8 2 6 2 4 1 8 12 0 2 Total 15 12 5