Skip to content

Commit 9a2d0fb

Browse files
committed
Fix check issues; add some vctrs methods
1 parent 0cb5d6c commit 9a2d0fb

File tree

7 files changed

+42
-5
lines changed

7 files changed

+42
-5
lines changed

DESCRIPTION

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ Encoding: UTF-8
99
Roxygen: list(markdown = TRUE)
1010
RoxygenNote: 7.3.2
1111
Imports:
12-
knitr
12+
knitr,
13+
vctrs
1314
Suggests:
15+
dplyr,
16+
glue,
1417
pander,
1518
rmarkdown,
1619
testthat (>= 3.0.0),

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
S3method(format,tab_list)
34
S3method(knit_print,tab_list)
45
S3method(knit_print,tab_tibble)
6+
S3method(print,tab_list)
57
export(knit_print)
68
export(new_tab_list)
79
export(new_tab_tibble)
10+
export(print_tablist_pander)
811
importFrom(knitr,knit_print)

R/knit_print.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ knitr::knit_print
55
#' Print a tab_tibble
66
#'
77
#' @param x The `tab_tibble` object to print
8+
#' @param ... Passed to subsequent methods
89
#' @returns `x` invisibly
910
#' @family knitters
1011
#' @export

R/objects.R

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,24 @@ new_tab_list <- function(x) {
2222
x_null <- vapply(X = x, FUN = is.null, FUN.VALUE = TRUE)
2323
x_df <- vapply(X = x, FUN = inherits, "data.frame", FUN.VALUE = TRUE)
2424
if (!all(x_null | x_df)) {
25-
rlang::abort("the contents of 'x' must be NULL or a 'data.frame'-like object")
25+
stop("the contents of 'x' must be NULL or a 'data.frame'-like object")
2626
}
2727
vctrs::new_vctr(x, class = "tab_list")
2828
}
29+
30+
vec_ptype_abbr.tab_list <- function(x, ...) {
31+
"tablist"
32+
}
33+
34+
#' @export
35+
format.tab_list <- function(x, ...) {
36+
rep("A tab_list object", length(x))
37+
}
38+
39+
#' @export
40+
print.tab_list <- function(x, ...) {
41+
for (idx in seq_along(x)) {
42+
print(x[[idx]], ...)
43+
}
44+
invisible(x)
45+
}

R/tablist_printers.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#' Print a tablist using `pander::pander()`
2-
#' @param name description
2+
#' @param x A table to print
3+
#' @param caption The caption for the table
4+
#' @param ... Passed to `pander::pander`
5+
#' @returns The result of `pander::pander`
6+
#' @export
37
print_tablist_pander <- function(x, caption, ...) {
48
auto_asis_start <- pander::panderOptions("knitr.auto.asis")
59
on.exit(pander::panderOptions(knitr.auto.asis = auto_asis_start))
610
pander::panderOptions(knitr.auto.asis = FALSE)
711

8-
pander::pander(x, caption = caption)
12+
pander::pander(x, caption = caption, ...)
913
}

man/knit_print.tab_tibble.Rd

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/print_tablist_pander.Rd

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)