From 639543db95f74493e47d5e2d98406c17e7d9700d Mon Sep 17 00:00:00 2001 From: Eli Pousson Date: Mon, 15 Aug 2022 23:56:45 -0700 Subject: [PATCH] style: adjust white space --- R/as_sf.R | 11 ++++++----- R/sf_to_df.R | 1 - R/st_buffer_ext.R | 3 ++- R/st_clip.R | 1 - R/st_join_ext.R | 4 ++-- R/write_sf_ext.R | 8 ++++---- README.Rmd | 6 +++--- README.md | 6 +++--- vignettes/introduction.Rmd | 4 ++-- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/R/as_sf.R b/R/as_sf.R index c04c9d6..52e9a15 100644 --- a/R/as_sf.R +++ b/R/as_sf.R @@ -93,11 +93,12 @@ as_bbox <- function(x, crs = NULL, ext = TRUE, ...) { switch(x_is, "sf_pt" = sf::st_bbox(st_buffer_ext(x, dist = 0.00000001), ...), "sf_or_sfc" = sf::st_bbox(x, ...), - "num_bbox" = sf::st_bbox(c( - xmin = x[1], ymin = x[2], - xmax = x[3], ymax = x[4] - ), - crs = crs, ... + "num_bbox" = sf::st_bbox( + c( + xmin = x[1], ymin = x[2], + xmax = x[3], ymax = x[4] + ), + crs = crs, ... ), "other" = sf::st_bbox(as_sf(x, ext = ext), ...) ) diff --git a/R/sf_to_df.R b/R/sf_to_df.R index bd62fed..95c0ec3 100644 --- a/R/sf_to_df.R +++ b/R/sf_to_df.R @@ -157,7 +157,6 @@ coords_df_to_sf <- function(x, coords = c("lon", "lat"), into = NULL, sep = ",", #' @export #' @importFrom janitor make_clean_names check_coords <- function(x = NULL, coords = NULL, default = c("lon", "lat"), rev = FALSE) { - # If x is a data frame if (!is.null(x) && is.data.frame(x)) { if (!has_coords(x, coords = coords, value = FALSE)) { diff --git a/R/st_buffer_ext.R b/R/st_buffer_ext.R index 54ec687..ecfbf06 100644 --- a/R/st_buffer_ext.R +++ b/R/st_buffer_ext.R @@ -91,7 +91,8 @@ st_buffer_ext <- function(x, dist = dist, dist_limits = dist_limits, unit = unit, - crs = crs) + crs = crs + ) x <- sf::st_buffer(x = x, dist = dist, singleSide = single_side, ...) diff --git a/R/st_clip.R b/R/st_clip.R index e6f7e2c..aabd26d 100644 --- a/R/st_clip.R +++ b/R/st_clip.R @@ -28,7 +28,6 @@ st_clip <- function(x, dist = NULL, diag_ratio = NULL, unit = "meter") { - # If bbox, convert to sf x <- as_sf(x) diff --git a/R/st_join_ext.R b/R/st_join_ext.R index 34ca61b..f0104e5 100644 --- a/R/st_join_ext.R +++ b/R/st_join_ext.R @@ -105,13 +105,13 @@ set_join_by_geom_type <- function(x, join = NULL) { all( is_multipolygon(x, by_geometry = TRUE) | is_polygon(x, by_geometry = TRUE) - ) + ) } else if (is_sf_list(x)) { x_is_poly <- all( sapply(x, is_polygon, by_geometry = TRUE) | sapply(x, is_multipolygon, by_geometry = TRUE) - ) + ) } if (x_is_poly) { diff --git a/R/write_sf_ext.R b/R/write_sf_ext.R index 217022b..53815de 100644 --- a/R/write_sf_ext.R +++ b/R/write_sf_ext.R @@ -338,11 +338,11 @@ write_sf_types <- function(data, if (!(filetype %in% c("rda", "rds", "RData"))) { ask <- is_interactive() && - cli_yeah( - c("{.arg data} is not a simple feature object.", - ">" = "Do you want to save {.arg data} as a RDA file?" + cli_yeah( + c("{.arg data} is not a simple feature object.", + ">" = "Do you want to save {.arg data} as a RDA file?" + ) ) - ) if (!ask) { invisible(return(NULL)) diff --git a/README.Rmd b/README.Rmd index 512c26f..c564a53 100644 --- a/README.Rmd +++ b/README.Rmd @@ -52,12 +52,12 @@ Combine data with st_union_ext: ```{r} random_id <- sample(nrow(nc), size = 8) -nc_union <- st_union_ext(nc[random_id,], name_col = "NAME") +nc_union <- st_union_ext(nc[random_id, ], name_col = "NAME") ggplot() + geom_sf(data = nc_union, aes(fill = NAME), alpha = 0.2) + - geom_sf_label(data = nc[random_id,], aes(label = NAME), size = 2) + - theme(legend.position="bottom") + geom_sf_label(data = nc[random_id, ], aes(label = NAME), size = 2) + + theme(legend.position = "bottom") ``` Make grids set rows, columns, and aspect ratios using st_make_grid_ext: diff --git a/README.md b/README.md index 91aafbd..cf54386 100644 --- a/README.md +++ b/README.md @@ -50,12 +50,12 @@ Combine data with st_union_ext: ``` r random_id <- sample(nrow(nc), size = 8) -nc_union <- st_union_ext(nc[random_id,], name_col = "NAME") +nc_union <- st_union_ext(nc[random_id, ], name_col = "NAME") ggplot() + geom_sf(data = nc_union, aes(fill = NAME), alpha = 0.2) + - geom_sf_label(data = nc[random_id,], aes(label = NAME), size = 2) + - theme(legend.position="bottom") + geom_sf_label(data = nc[random_id, ], aes(label = NAME), size = 2) + + theme(legend.position = "bottom") #> Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not #> give correct results for longitude/latitude data ``` diff --git a/vignettes/introduction.Rmd b/vignettes/introduction.Rmd index 184a8e5..069b0a1 100644 --- a/vignettes/introduction.Rmd +++ b/vignettes/introduction.Rmd @@ -222,7 +222,7 @@ There are also several functions that return information about the geometry of i The `get_length()` function wraps `sf::st_length` and (for POLYGON geometries only) `lwgeom::st_perimeter`: ```{r} -example_line <- as_line(as_point(nc[1,]), as_point(nc[2,]), crs = 4326) +example_line <- as_line(as_point(nc[1, ]), as_point(nc[2, ]), crs = 4326) glimpse(get_length(example_line)) ``` @@ -230,7 +230,7 @@ glimpse(get_length(example_line)) The `get_area()` function wraps `sf::st_area`: ```{r} -glimpse(get_area(nc[1:3,], unit = "mi^2")) +glimpse(get_area(nc[1:3, ], unit = "mi^2")) ``` `get_dist()` supports a more varied range of options including using the "to" parameter to define a corner or center of the input sf object bounding box.