Closed matt-dray closed 2 years ago
See https://github.com/co-analysis/a11ytables/issues/23#issuecomment-1040770622. Given how much nicer it looks I'd consider using {pillar} directly and just taking at as an import. If you did need to lighten dependencies at a later date you then only need to focus on printing and formatting.
Setting the class as c("a11ytable", "tbl", "data.frame")
then, once you've added {pillar} as an import the only extra code you would need is something like
#' @importFrom pillar tbl_sum
NULL
#' @export
tbl_sum.a11ytables <- function(x, ...) {
header <- sprintf(
"%s x %s",
formatC(nrow(x), big.mark = ","),
formatC(ncol(x), big.mark = ",")
)
c("a11ytables" = header)
}
@TimTaylor This approach is now in the package and I've added you as a contributor. PR for any changes you want to your details in the DESCRIPTION.
As it stands, a11ytable-class objects are data.frames. It would be nice to view them as tibbles if the user has {tibble} installed/loaded. {a11ytables} seeks to be low-dependency—besides {openxlsx}—so doesn't import the tidyverse.
See this PR to {palmerpenguins} for how this could be done.
Might reduce the need for writing a specific print method (#23)?