Skip to content

Commit

Permalink
Fix build on 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Sep 6, 2024
1 parent a8b15b4 commit 6ec6d1b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ importFrom(grid,seekViewport)
importFrom(grid,unit)
importFrom(grid,unit.c)
importFrom(grid,unit.pmax)
importFrom(grid,unitType)
importFrom(grid,upViewport)
importFrom(grid,valid.just)
importFrom(grid,viewport)
Expand Down
2 changes: 1 addition & 1 deletion R/plot_patchwork.R
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ find_strip_pos <- function(gt) {
}
'inside'
}
#' @importFrom grid unitType

set_panel_dimensions <- function(gt, panels, widths, heights, fixed_asp, design) {
width_ind <- seq(PANEL_COL, by = TABLE_COLS, length.out = length(widths))
height_ind <- seq(PANEL_ROW, by = TABLE_ROWS, length.out = length(heights))
Expand Down
2 changes: 1 addition & 1 deletion R/wrap_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#' # the size of the area they occupy
#' p2 <- ggplot(airquality) +
#' geom_boxplot(aes(y = month.name[Month], x = Temp)) +
#' scale_y_discrete(name = NULL, limits = month.name[5:9], guide = "none")
#' scale_y_discrete(name = NULL, limits = month.name[9:5], guide = "none")
#'
#' wrap_table(gt_tab, space = "fixed") + p2
#'
Expand Down
22 changes: 20 additions & 2 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@ register_s3_method <- function(pkg, generic, class, fun = NULL) {
}
)
}
on_load(

unitType <- function(x) {
unit <- attr(x, "unit")
if (!is.null(unit)) {
return(unit)
}
if (is.list(x) && is.unit(x[[1]])) {
unit <- vapply(x, unitType, character(1))
return(unit)
} else if ("fname" %in% names(x)) {
return(x$fname)
}
rep("", length(x)) # we're only interested in simple units for now
}

on_load({
register_s3_method("vdiffr", "print_plot", "patchwork")
)
if ("unitType" %in% getNamespaceExports("grid")) {
unitType <- grid::unitType
}
})
2 changes: 1 addition & 1 deletion man/wrap_table.Rd

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

0 comments on commit 6ec6d1b

Please sign in to comment.