This function adds the column variable name to the top of a tabyl for a complete display of information. This makes the tabyl prettier, but renders the data.frame less useful for further manipulation.

adorn_col_title(dat, placement = "top")

Arguments

dat

a data.frame of class tabyl.

placement

whether the column name should be added to the top of the tabyl in an otherwise-empty row "top" or appended to the already-present row name variable ("combined"). The formatting in the "top" option has the look of base R's table(); it also wipes out the other column names, making it hard to further use the data.frame besides formatting it for reporting. The "combined" option is more conservative in this regard.

Value

the input tabyl, augmented with the column title.

Examples

mtcars %>% tabyl(am, cyl) %>% adorn_col_title(placement = "top")
#> Error in adorn_col_title(., placement = "top"): object 'ns' not found