Skip to content

Commit

Permalink
Fixes for submission
Browse files Browse the repository at this point in the history
  • Loading branch information
hafen committed Nov 29, 2023
1 parent debae68 commit 6e8bc63
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions R/facet_geo.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,15 @@ plot.facet_geo <- function(x, ...) {
#' @param x a data frame containing a grid
#' @param label the column name in \code{x} that should be used for text labels in the grid plot
#' @param label_raw the column name in the optional SpatialPolygonsDataFrame attached to \code{x} that should be used for text labels in the raw geography plot
#' @param do_plot should the grid preview be plotted?
#' @export
#' @importFrom ggplot2 ggplot geom_rect geom_text aes xlim ylim
#' @importFrom gridExtra grid.arrange
#' @importFrom rlang .data
#' @examples
#' grid_preview(us_state_grid2)
#' grid_preview(eu_grid1, label = "name")
grid_preview <- function(x, label = NULL, label_raw = NULL) {
grid_preview <- function(x, label = NULL, label_raw = NULL, do_plot = TRUE) {

if (!inherits(x, "geofacet_grid"))
x <- get_grid(x)
Expand Down Expand Up @@ -221,7 +222,8 @@ grid_preview <- function(x, label = NULL, label_raw = NULL) {
p2 <- plot_geo_raw(spdf, label = label_raw)
p <- gridExtra::grid.arrange(p2, p, nrow = 1)
} else {
suppressWarnings(plot(p))
if (do_plot)
plot(p)
}
invisible(p)
}
Expand Down
4 changes: 3 additions & 1 deletion man/grid_preview.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/test-grids.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ library(ggplot2)

test_that("grids all load and work correctly", {
for (grd in .valid_grids)
expect_no_error(grid_preview(grd))
expect_no_error(prv <- grid_preview(grd, do_plot = FALSE))
})

0 comments on commit 6e8bc63

Please sign in to comment.