Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add draw=TRUE parameter to condformat2grob function #31

Merged
merged 1 commit into from Nov 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: condformat
Type: Package
Title: Conditional Formatting in Data Frames
Version: 0.9.0.9000
Version: 0.9.1
Date: 2020-05-11
Authors@R: person(given = "Sergio", family = "Oller Moreno",
email = "sergioller@gmail.com", role = c("aut", "cph", "cre"),
Expand Down Expand Up @@ -41,5 +41,5 @@ Suggests:
testthat (>= 1.0)
VignetteBuilder: knitr
Encoding: UTF-8
RoxygenNote: 7.1.0
RoxygenNote: 7.2.2.9000
Roxygen: list(markdown = TRUE)
8 changes: 8 additions & 0 deletions NEWS.md
@@ -1,3 +1,11 @@
# condformat 0.9.1

## New features

* `condformat2grob` function takes an optional `draw=TRUE` parameter which
controls whether the grob is immediately drawn during the function call.
`draw=FALSE` allows easier use in composite figures with grid.arrange/ggarrange.

# condformat 0.9.0.9000

## Other
Expand Down
12 changes: 9 additions & 3 deletions R/render_gtable.R
@@ -1,6 +1,10 @@
#' Converts the table to a grid object
#'
#' @param x A condformat_tbl object
#' @param draw Boolean value (default TRUE). If TRUE, the table is
#' immediately drawn using grid::draw and the grob is returned.
#' If FALSE, the grob is returned without drawing. Set draw=FALSE
#' when using the grob in composite images with grid.arrange/ggarrange.
#' @return the grid object
#' @examples
#' library(condformat)
Expand All @@ -9,7 +13,7 @@
#' condformat %>%
#' condformat2grob
#' @export
condformat2grob <- function(x) {
condformat2grob <- function(x, draw=TRUE) {
xv_cf <- get_xview_and_cf_fields(x)
xview <- xv_cf[["xview"]]
cf_fields <- xv_cf[["cf_fields"]]
Expand All @@ -27,8 +31,10 @@ condformat2grob <- function(x) {
has_rownames <- !("rows" %in% names(tableGrobArgs) && is.null(tableGrobArgs[["rows"]]))
has_colnames <- !is.null(final_colnames)
gridobj <- render_cf_fields_to_grob(cf_fields, xview, gridobj, has_rownames, has_colnames)
grid::grid.newpage()
grid::grid.draw(gridobj)
if(draw==TRUE){
grid::grid.newpage()
grid::grid.draw(gridobj)
}
invisible(gridobj)
}

Expand Down
7 changes: 6 additions & 1 deletion man/condformat2grob.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.