diff --git a/DESCRIPTION b/DESCRIPTION index 7e4f1436f..6031ca8e6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: rtables Title: Reporting Tables -Version: 0.1.0.5 +Version: 0.1.0.6 Authors@R: c( person("Adrian", "Waddell", email = "adrian.waddell@roche.com", role = c("aut", "cre")) ) @@ -18,7 +18,7 @@ Suggests: License: Apache License 2.0 | file LICENSE Encoding: UTF-8 LazyData: true -RoxygenNote: 6.0.1 +RoxygenNote: 6.1.0 VignetteBuilder: knitr URL: https://github.com/roche/rtables, https://roche.github.io/rtables/ BugReports: https://github.com/roche/rtables/issues diff --git a/NEWS.md b/NEWS.md index 7d544020a..743bf8e59 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,9 @@ +## rtable 0.1.0.6 + +* `Viewer` now also accepts objects of class `shiny.tag` (defined in package `htmltools`) +* `as.html` accepts `class.table`, `class.tr`, `class.th`, and `class.td` as an argument + ## rtable 0.1.0.5 * added `sprintf_format` for formatting rcells (thanks to Doug Kelkhoff for the suggestion) diff --git a/R/Viewer.R b/R/Viewer.R index 66539b2ab..45e8b588f 100644 --- a/R/Viewer.R +++ b/R/Viewer.R @@ -3,31 +3,64 @@ #' #' The table will be displayed using the bootstrap styling for tables. #' -#' @inheritParams dim.rtable -#' @param y optional second rtable object +#' @param x object of class \code{rtable} or \code{shiny.tag} (defined in \code{htmltools}) +#' @param y optional second argument of same type as \code{x} #' @param row.names.bold row.names.bold boolean, make rownames bold +#' @param ... arguments passed to \code{as_html} #' #' #' @export -Viewer <- function(x, y = NULL, row.names.bold = FALSE) { +#' +#' +#' @examples +#' +#' \dontrun{ +#' sl5 <- factor(iris$Sepal.Length > 5, levels = c(TRUE, FALSE), +#' labels = c("S.L > 5", "S.L <= 5")) +#' +#' tbl <- rtabulate(iris$Species, col_by=sl5) +#' +#' Viewer(tbl) +#' Viewer(tbl, tbl) +#' +#' +#' tbl2 <-htmltools::tags$div( +#' class = "table-responsive", +#' as_html(tbl, class.table = "table") +#' ) +#' +#' Viewer(tbl, tbl2) +#' +#' } +Viewer <- function(x, y = NULL, row.names.bold = FALSE, ...) { - if (!is(x, "rtable")) stop("x is expected to be an rtable") - if (!is.null(y) && !is(y, "rtable")) stop("y is expected to be an rtable if specified") + check_convert <- function(x, name, accept_NULL = FALSE) { + if (accept_NULL && is.null(x)) { + NULL + } else if (is(x, "shiny.tag")) { + x + } else if (is(x, "rtable")) { + as_html(x, ...) + } else { + stop("object of class rtable or shiny tag excepted for ", name) + } + } - viewer <- getOption("viewer") + x_tag <- check_convert(x, "x", FALSE) + y_tag <- check_convert(y, "y", TRUE) - tbl_html <- if (is.null(y)) { - as_html(x) + html_output <- if (is.null(y)) { + x_tag } else { htmltools::tags$div( class = ".container-fluid", htmltools::tags$div( class= "col-xs-6", - as_html(x) + x_tag ), htmltools::tags$div( class= "col-xs-6", - as_html(y) + y_tag ) ) } @@ -42,12 +75,13 @@ Viewer <- function(x, y = NULL, row.names.bold = FALSE) { } # get html name - for (i in 1:10000) { + n_try <- 10000 + for (i in seq_len(n_try)) { htmlFile <- file.path(sandbox_folder, paste0("table", i, ".html")) if (!file.exists(htmlFile)) { break - } else if (i == 10000) { + } else if (i == n_try) { stop("too many html rtables created, restart your session") } } @@ -62,7 +96,7 @@ Viewer <- function(x, y = NULL, row.names.bold = FALSE) { tags$link(href="css/bootstrap.min.css", rel="stylesheet") ), tags$body( - tbl_html + html_output ) ) @@ -71,7 +105,6 @@ Viewer <- function(x, y = NULL, row.names.bold = FALSE) { file = htmlFile, append = FALSE ) - viewer <- getOption("viewer") if (!is.null(viewer)) { diff --git a/R/as_html.R b/R/as_html.R index e04741e81..9b0cdb1ce 100644 --- a/R/as_html.R +++ b/R/as_html.R @@ -23,6 +23,10 @@ #' #' as_html(tbl) #' +#' as_html(tbl, class.table = "table", class.tr = "row") +#' +#' as_html(tbl, class.td = "aaa") +#' as_html <- function(x, ...) { UseMethod("as_html", x) } @@ -43,38 +47,42 @@ as_html.default <- function(x, ...) { # Convert an rtable object to html # # @param x an object of class \code{\link{rtable}} -# @param class class attributes for the table in html -# @param ... arguments passed on to \code{shiny::tags$table} +# @param class.table class attributes for the table in html +# @param ... arguments passed on to methods # # @return an object of class \code{shinyTag} #' @export -as_html.rtable <- function(x, class = "table table-condensed table-hover", - body_cell_class = NULL, - header_cell_class = NULL, +as_html.rtable <- function(x, class.table = "table table-condensed table-hover", ...) { ncol <- ncol(x) header <- attr(x, "header") body <- x - - tags$table( - class = class, - # tags$tr(tagList(tags$th(""), lapply(col_headers, tags$th, align="center", class="text-center"))), - lapply(header, as_html, ncol = ncol, cell_tag = tags$th, ...), - lapply(x, as_html, ncol = ncol, ...) + class = class.table, + lapply(header, as_html, ncol = ncol, is_header = TRUE, ...), + lapply(body, as_html, ncol = ncol, is_header = FALSE, ...) ) } #' @export -as_html.rrow <- function(x, ncol, cell_tag = tags$td, ...) { +as_html.rrow <- function(x, ncol, is_header, + class.tr = NULL, class.td = NULL, class.th = NULL, ...) { + + (is.logical(is_header) && length(is_header) == 1) || stop("is_header is supposed to be a boolean") + + cell_tag <- if (is_header) { + function(...) tags$th(class = class.th, ...) + } else { + function(...) tags$td(class = class.td, ...) + } indent <- attr(x, "indent") - row.name <- attr(x,"row.name") + row.name <- attr(x, "row.name") cells <- if (length(x) == 0) { cell_tag(row.name, class=paste("rowname", "text-left"), colspan = as.character(ncol+1)) @@ -105,5 +113,5 @@ as_html.rrow <- function(x, ncol, cell_tag = tags$td, ...) { } } - tags$tr(cells) + tags$tr(cells, class = class.tr) } \ No newline at end of file diff --git a/docs/dev/ISSUE_TEMPLATE.html b/docs/dev/ISSUE_TEMPLATE.html index a12db9a08..5a3c8edd6 100644 --- a/docs/dev/ISSUE_TEMPLATE.html +++ b/docs/dev/ISSUE_TEMPLATE.html @@ -58,7 +58,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/LICENSE-text.html b/docs/dev/LICENSE-text.html index 438b0e4da..ca65e5e36 100644 --- a/docs/dev/LICENSE-text.html +++ b/docs/dev/LICENSE-text.html @@ -58,7 +58,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/articles/index.html b/docs/dev/articles/index.html index f0f011711..1af03e604 100644 --- a/docs/dev/articles/index.html +++ b/docs/dev/articles/index.html @@ -58,7 +58,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/articles/rtables.html b/docs/dev/articles/rtables.html index 1842acddc..a6c046809 100644 --- a/docs/dev/articles/rtables.html +++ b/docs/dev/articles/rtables.html @@ -30,7 +30,7 @@ rtables - 0.1.0.5 + 0.1.0.6 @@ -86,7 +86,7 @@

Introduction to rtables

Adrian Waddell

-

2018-09-21

+

2018-10-22

Source: vignettes/rtables.Rmd diff --git a/docs/dev/articles/rtabulate.html b/docs/dev/articles/rtabulate.html index da60de6e6..a71f2e958 100644 --- a/docs/dev/articles/rtabulate.html +++ b/docs/dev/articles/rtabulate.html @@ -30,7 +30,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/authors.html b/docs/dev/authors.html index b2d02f596..46ef0f087 100644 --- a/docs/dev/authors.html +++ b/docs/dev/authors.html @@ -58,7 +58,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/index.html b/docs/dev/index.html index 63294a7f0..c4514fc0e 100644 --- a/docs/dev/index.html +++ b/docs/dev/index.html @@ -32,7 +32,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/news/index.html b/docs/dev/news/index.html index eb40ec04f..100cd70d2 100644 --- a/docs/dev/news/index.html +++ b/docs/dev/news/index.html @@ -58,7 +58,7 @@ rtables - 0.1.0.5 + 0.1.0.6 @@ -116,6 +116,16 @@

Changelog

Source: NEWS.md +
+

+rtable 0.1.0.6

+ +

rtable 0.1.0.5

@@ -155,6 +165,7 @@

Contents

@@ -129,32 +129,58 @@

Dispaly an rtable object in the Viewe

-
Viewer(x, y = NULL, row.names.bold = FALSE)
+
Viewer(x, y = NULL, row.names.bold = FALSE, ...)

Arguments

- + - + + + + +
x

an rtable object

object of class rtable or shiny.tag (defined in htmltools)

y

optional second rtable object

optional second argument of same type as x

row.names.bold

row.names.bold boolean, make rownames bold

...

arguments passed to as_html

+

Examples

+
+
# NOT RUN { +sl5 <- factor(iris$Sepal.Length > 5, levels = c(TRUE, FALSE), + labels = c("S.L > 5", "S.L <= 5")) + +tbl <- rtabulate(iris$Species, col_by=sl5) + +Viewer(tbl) +Viewer(tbl, tbl) + + +tbl2 <-htmltools::tags$div( + class = "table-responsive", + as_html(tbl, class.table = "table") +) + +Viewer(tbl, tbl2) + +# }
diff --git a/docs/dev/reference/as.rtable.html b/docs/dev/reference/as.rtable.html index db0219a87..b84a3d36f 100644 --- a/docs/dev/reference/as.rtable.html +++ b/docs/dev/reference/as.rtable.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/as.rtable.table.html b/docs/dev/reference/as.rtable.table.html index e8e8000d6..bd8c3711e 100644 --- a/docs/dev/reference/as.rtable.table.html +++ b/docs/dev/reference/as.rtable.table.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/as_html.default.html b/docs/dev/reference/as_html.default.html index 0129fcdda..08e00263b 100644 --- a/docs/dev/reference/as_html.default.html +++ b/docs/dev/reference/as_html.default.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/as_html.html b/docs/dev/reference/as_html.html index 8e0f13210..49f42884b 100644 --- a/docs/dev/reference/as_html.html +++ b/docs/dev/reference/as_html.html @@ -63,7 +63,7 @@ rtables - 0.1.0.5 + 0.1.0.6 @@ -182,6 +182,52 @@

Examp #> <td class="rowname text-left" colspan="4" style="padding-left: 6ch">r3</td> #> </tr> #> </table>
+as_html(tbl, class.table = "table", class.tr = "row")
#> <table class="table"> +#> <tr class="row"> +#> <th class="rowname text-left"></th> +#> <th class="text-center">A</th> +#> <th class="text-center">B</th> +#> <th class="text-center">C</th> +#> </tr> +#> <tr class="row"> +#> <td class="rowname text-left">r1</td> +#> <td class="text-center">1</td> +#> <td class="text-center">2</td> +#> <td class="text-center">3</td> +#> </tr> +#> <tr class="row"> +#> <td class="rowname text-left" style="padding-left: 3ch">r2</td> +#> <td class="text-center">4</td> +#> <td class="text-center">3</td> +#> <td class="text-center">2</td> +#> </tr> +#> <tr class="row"> +#> <td class="rowname text-left" colspan="4" style="padding-left: 6ch">r3</td> +#> </tr> +#> </table>
+as_html(tbl, class.td = "aaa")
#> <table class="table table-condensed table-hover"> +#> <tr> +#> <th class="rowname text-left"></th> +#> <th class="text-center">A</th> +#> <th class="text-center">B</th> +#> <th class="text-center">C</th> +#> </tr> +#> <tr> +#> <td class="aaa rowname text-left">r1</td> +#> <td class="aaa text-center">1</td> +#> <td class="aaa text-center">2</td> +#> <td class="aaa text-center">3</td> +#> </tr> +#> <tr> +#> <td class="aaa rowname text-left" style="padding-left: 3ch">r2</td> +#> <td class="aaa text-center">4</td> +#> <td class="aaa text-center">3</td> +#> <td class="aaa text-center">2</td> +#> </tr> +#> <tr> +#> <td class="aaa rowname text-left" colspan="4" style="padding-left: 6ch">r3</td> +#> </tr> +#> </table>
diff --git a/docs/dev/reference/dim.rheader.html b/docs/dev/reference/dim.rheader.html index 4d63c338e..29ab3055c 100644 --- a/docs/dev/reference/dim.rheader.html +++ b/docs/dev/reference/dim.rheader.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/dim.rtable.html b/docs/dev/reference/dim.rtable.html index 167d2044a..1f0be8171 100644 --- a/docs/dev/reference/dim.rtable.html +++ b/docs/dev/reference/dim.rtable.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/format_rcell.html b/docs/dev/reference/format_rcell.html index d6d78c4b3..7c8025c6e 100644 --- a/docs/dev/reference/format_rcell.html +++ b/docs/dev/reference/format_rcell.html @@ -64,7 +64,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/header-set.html b/docs/dev/reference/header-set.html index fb9ef8f29..89ee28da6 100644 --- a/docs/dev/reference/header-set.html +++ b/docs/dev/reference/header-set.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/header.html b/docs/dev/reference/header.html index abdf7dce1..1d3ac08fa 100644 --- a/docs/dev/reference/header.html +++ b/docs/dev/reference/header.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/indented_row.names.html b/docs/dev/reference/indented_row.names.html index 2c74f43b6..2a0e56817 100644 --- a/docs/dev/reference/indented_row.names.html +++ b/docs/dev/reference/indented_row.names.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/index.html b/docs/dev/reference/index.html index d0e507d43..8e37d26a5 100644 --- a/docs/dev/reference/index.html +++ b/docs/dev/reference/index.html @@ -58,7 +58,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/is.no_by.html b/docs/dev/reference/is.no_by.html index 1fa75b4bf..05c665ad7 100644 --- a/docs/dev/reference/is.no_by.html +++ b/docs/dev/reference/is.no_by.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/list_rcell_format_labels.html b/docs/dev/reference/list_rcell_format_labels.html index c275477e2..657dc9327 100644 --- a/docs/dev/reference/list_rcell_format_labels.html +++ b/docs/dev/reference/list_rcell_format_labels.html @@ -62,7 +62,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/names.rtable.html b/docs/dev/reference/names.rtable.html index 0b04f8996..3f556cca5 100644 --- a/docs/dev/reference/names.rtable.html +++ b/docs/dev/reference/names.rtable.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/no_by.html b/docs/dev/reference/no_by.html index f7a904457..988fa19b6 100644 --- a/docs/dev/reference/no_by.html +++ b/docs/dev/reference/no_by.html @@ -63,7 +63,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/rbind.rtable.html b/docs/dev/reference/rbind.rtable.html index 1118e4916..54c2d5bf6 100644 --- a/docs/dev/reference/rbind.rtable.html +++ b/docs/dev/reference/rbind.rtable.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/rcell.html b/docs/dev/reference/rcell.html index 8866fb14d..afcce22ea 100644 --- a/docs/dev/reference/rcell.html +++ b/docs/dev/reference/rcell.html @@ -62,7 +62,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/rheader.html b/docs/dev/reference/rheader.html index a6364d9cf..54a6d6519 100644 --- a/docs/dev/reference/rheader.html +++ b/docs/dev/reference/rheader.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/row.names-set-.rtable.html b/docs/dev/reference/row.names-set-.rtable.html index 91cdc4924..49542290d 100644 --- a/docs/dev/reference/row.names-set-.rtable.html +++ b/docs/dev/reference/row.names-set-.rtable.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/row.names.rheader.html b/docs/dev/reference/row.names.rheader.html index db7bfeabb..1b2582b74 100644 --- a/docs/dev/reference/row.names.rheader.html +++ b/docs/dev/reference/row.names.rheader.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/row.names.rtable.html b/docs/dev/reference/row.names.rtable.html index 2d6aa3f58..ed6b0e04d 100644 --- a/docs/dev/reference/row.names.rtable.html +++ b/docs/dev/reference/row.names.rtable.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/rrow.html b/docs/dev/reference/rrow.html index b1d3f1e24..3bfde49a6 100644 --- a/docs/dev/reference/rrow.html +++ b/docs/dev/reference/rrow.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/rrowl.html b/docs/dev/reference/rrowl.html index 104627145..fe7ba2a15 100644 --- a/docs/dev/reference/rrowl.html +++ b/docs/dev/reference/rrowl.html @@ -62,7 +62,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/rtable.html b/docs/dev/reference/rtable.html index 1246305f4..a6e43b4da 100644 --- a/docs/dev/reference/rtable.html +++ b/docs/dev/reference/rtable.html @@ -62,7 +62,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/rtablel.html b/docs/dev/reference/rtablel.html index f393af095..6894b28f7 100644 --- a/docs/dev/reference/rtablel.html +++ b/docs/dev/reference/rtablel.html @@ -62,7 +62,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/rtabulate.data.frame.html b/docs/dev/reference/rtabulate.data.frame.html index 13408a860..ffb426caa 100644 --- a/docs/dev/reference/rtabulate.data.frame.html +++ b/docs/dev/reference/rtabulate.data.frame.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 @@ -128,8 +128,9 @@

Split data.frame and apply functions

# S3 method for data.frame
 rtabulate(x, row_by_var = no_by("row_1"),
-  col_by_var = no_by("col_1"), FUN = nrow, ..., row_col_data_args = FALSE,
-  format = "xx", indent = 0, col_total = "(N=xx)")
+ col_by_var = no_by("col_1"), FUN = nrow, ..., + row_col_data_args = FALSE, format = "xx", indent = 0, + col_total = "(N=xx)")

Arguments

diff --git a/docs/dev/reference/rtabulate.factor.html b/docs/dev/reference/rtabulate.factor.html index c6e13fe67..b1f2651e5 100644 --- a/docs/dev/reference/rtabulate.factor.html +++ b/docs/dev/reference/rtabulate.factor.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 @@ -127,8 +127,8 @@

Tabulate Factors

# S3 method for factor
-rtabulate(x, col_by = no_by("col_1"), FUN = length, ...,
-  row_col_data_args = FALSE, useNA = c("no", "ifany", "always"),
+rtabulate(x, col_by = no_by("col_1"), FUN = length,
+  ..., row_col_data_args = FALSE, useNA = c("no", "ifany", "always"),
   format = "xx", indent = 0, col_total = "(N=xx)")

Arguments

diff --git a/docs/dev/reference/rtabulate.html b/docs/dev/reference/rtabulate.html index 90215c589..959203445 100644 --- a/docs/dev/reference/rtabulate.html +++ b/docs/dev/reference/rtabulate.html @@ -63,7 +63,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/rtabulate.logical.html b/docs/dev/reference/rtabulate.logical.html index 41e53236f..fd7811e23 100644 --- a/docs/dev/reference/rtabulate.logical.html +++ b/docs/dev/reference/rtabulate.logical.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 @@ -127,10 +127,10 @@

tabulate a logical vector

# S3 method for logical
-rtabulate(x, col_by = no_by("col_1"), FUN = function(x)
-  sum(x) * c(1, 1/length(x)), ..., row_data_arg = FALSE,
-  format = "xx.xx (xx.xx%)", row.name = "", indent = 0,
-  col_total = "(N=xx)")
+rtabulate(x, col_by=no_by("col_1"), + FUN=function(x) sum(x) * c(1, 1/length(x)), ..., + row_data_arg=FALSE, format="xx.xx (xx.xx%)", row.name="", + indent=0, col_total="(N=xx)")

Arguments

diff --git a/docs/dev/reference/rtabulate.numeric.html b/docs/dev/reference/rtabulate.numeric.html index 1e78e63dd..12bea0daa 100644 --- a/docs/dev/reference/rtabulate.numeric.html +++ b/docs/dev/reference/rtabulate.numeric.html @@ -62,7 +62,7 @@ rtables - 0.1.0.5 + 0.1.0.6 @@ -129,9 +129,9 @@

tabulate a numeric vector

# S3 method for numeric
-rtabulate(x, col_by = no_by("col_1"), FUN = mean, ...,
-  row_data_arg = FALSE, format = NULL, row.name = NULL, indent = 0,
-  col_total = "(N=xx)")
+rtabulate(x, col_by=no_by("col_1"), FUN=mean, + ..., row_data_arg=FALSE, format=NULL, row.name=NULL, + indent=0, col_total="(N=xx)")

Arguments

diff --git a/docs/dev/reference/sprintf_format.html b/docs/dev/reference/sprintf_format.html index c651a7e84..2fe0dee24 100644 --- a/docs/dev/reference/sprintf_format.html +++ b/docs/dev/reference/sprintf_format.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/sub-.rheader.html b/docs/dev/reference/sub-.rheader.html index 0cd10a589..3bb461457 100644 --- a/docs/dev/reference/sub-.rheader.html +++ b/docs/dev/reference/sub-.rheader.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/sub-.rtable.html b/docs/dev/reference/sub-.rtable.html index 924abb128..46ea08f14 100644 --- a/docs/dev/reference/sub-.rtable.html +++ b/docs/dev/reference/sub-.rtable.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/docs/dev/reference/toString.rtable.html b/docs/dev/reference/toString.rtable.html index 018bb3f87..2f0704393 100644 --- a/docs/dev/reference/toString.rtable.html +++ b/docs/dev/reference/toString.rtable.html @@ -61,7 +61,7 @@ rtables - 0.1.0.5 + 0.1.0.6 diff --git a/man/Viewer.Rd b/man/Viewer.Rd index 8abe20b9a..ae030f7b9 100644 --- a/man/Viewer.Rd +++ b/man/Viewer.Rd @@ -5,15 +5,38 @@ \title{Dispaly an \code{\link{rtable}} object in the Viewer pane in RStudio or in a browser} \usage{ -Viewer(x, y = NULL, row.names.bold = FALSE) +Viewer(x, y = NULL, row.names.bold = FALSE, ...) } \arguments{ -\item{x}{an \code{\link{rtable}} object} +\item{x}{object of class \code{rtable} or \code{shiny.tag} (defined in \code{htmltools})} -\item{y}{optional second rtable object} +\item{y}{optional second argument of same type as \code{x}} \item{row.names.bold}{row.names.bold boolean, make rownames bold} + +\item{...}{arguments passed to \code{as_html}} } \description{ The table will be displayed using the bootstrap styling for tables. } +\examples{ + +\dontrun{ +sl5 <- factor(iris$Sepal.Length > 5, levels = c(TRUE, FALSE), + labels = c("S.L > 5", "S.L <= 5")) + +tbl <- rtabulate(iris$Species, col_by=sl5) + +Viewer(tbl) +Viewer(tbl, tbl) + + +tbl2 <-htmltools::tags$div( + class = "table-responsive", + as_html(tbl, class.table = "table") +) + +Viewer(tbl, tbl2) + +} +} diff --git a/man/as_html.Rd b/man/as_html.Rd index c4d5edf08..17b2f08e1 100644 --- a/man/as_html.Rd +++ b/man/as_html.Rd @@ -30,4 +30,8 @@ tbl <- rtable( as_html(tbl) +as_html(tbl, class.table = "table", class.tr = "row") + +as_html(tbl, class.td = "aaa") + } diff --git a/man/rtabulate.data.frame.Rd b/man/rtabulate.data.frame.Rd index 2f4777a1f..9528d0657 100644 --- a/man/rtabulate.data.frame.Rd +++ b/man/rtabulate.data.frame.Rd @@ -5,8 +5,9 @@ \title{Split data.frame and apply functions} \usage{ \method{rtabulate}{data.frame}(x, row_by_var = no_by("row_1"), - col_by_var = no_by("col_1"), FUN = nrow, ..., row_col_data_args = FALSE, - format = "xx", indent = 0, col_total = "(N=xx)") + col_by_var = no_by("col_1"), FUN = nrow, ..., + row_col_data_args = FALSE, format = "xx", indent = 0, + col_total = "(N=xx)") } \arguments{ \item{x}{a vecor} diff --git a/man/rtabulate.factor.Rd b/man/rtabulate.factor.Rd index dec2b0c3f..dce879198 100644 --- a/man/rtabulate.factor.Rd +++ b/man/rtabulate.factor.Rd @@ -4,8 +4,8 @@ \alias{rtabulate.factor} \title{Tabulate Factors} \usage{ -\method{rtabulate}{factor}(x, col_by = no_by("col_1"), FUN = length, ..., - row_col_data_args = FALSE, useNA = c("no", "ifany", "always"), +\method{rtabulate}{factor}(x, col_by = no_by("col_1"), FUN = length, + ..., row_col_data_args = FALSE, useNA = c("no", "ifany", "always"), format = "xx", indent = 0, col_total = "(N=xx)") } \arguments{ diff --git a/man/rtabulate.logical.Rd b/man/rtabulate.logical.Rd index 9f029dda1..4d6534cbd 100644 --- a/man/rtabulate.logical.Rd +++ b/man/rtabulate.logical.Rd @@ -4,10 +4,10 @@ \alias{rtabulate.logical} \title{tabulate a logical vector} \usage{ -\method{rtabulate}{logical}(x, col_by = no_by("col_1"), FUN = function(x) - sum(x) * c(1, 1/length(x)), ..., row_data_arg = FALSE, - format = "xx.xx (xx.xx\%)", row.name = "", indent = 0, - col_total = "(N=xx)") +\method{rtabulate}{logical}(x, col_by = no_by("col_1"), + FUN = function(x) sum(x) * c(1, 1/length(x)), ..., + row_data_arg = FALSE, format = "xx.xx (xx.xx\%)", row.name = "", + indent = 0, col_total = "(N=xx)") } \arguments{ \item{x}{a vecor} diff --git a/man/rtabulate.numeric.Rd b/man/rtabulate.numeric.Rd index 37b691dff..d740f1cde 100644 --- a/man/rtabulate.numeric.Rd +++ b/man/rtabulate.numeric.Rd @@ -4,9 +4,9 @@ \alias{rtabulate.numeric} \title{tabulate a numeric vector} \usage{ -\method{rtabulate}{numeric}(x, col_by = no_by("col_1"), FUN = mean, ..., - row_data_arg = FALSE, format = NULL, row.name = NULL, indent = 0, - col_total = "(N=xx)") +\method{rtabulate}{numeric}(x, col_by = no_by("col_1"), FUN = mean, + ..., row_data_arg = FALSE, format = NULL, row.name = NULL, + indent = 0, col_total = "(N=xx)") } \arguments{ \item{x}{a vecor}