Skip to content

Commit

Permalink
docs: fill missing parameter definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
elipousson committed Jul 25, 2022
1 parent 071e433 commit bce07b6
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 7 deletions.
6 changes: 6 additions & 0 deletions R/as_sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#' [as_sf_list()] only supports sf objects or a data frames with a sf list
#' column named "data" (typically created by using [dplyr::group_nest()] on an
#' sf object.
#' @param ext If `TRUE`, [as_sf] will convert a data frame or character vector
#' of addresses to an sf object using [df_to_sf] or [address_to_sf]. If
#' `FALSE`, only spatial objects (bbox, sfg, sfc, sf list, raster, or sp
#' objects) can be converted. Defaults to `TRUE`.
#' @param sf_col A column name to use for the geometry column created by
#' [as_sf]; defaults to "geometry".
#' @param crs Coordinate reference system for `sf`, `bbox`, `sfc` or `sf` list
Expand Down Expand Up @@ -198,6 +202,8 @@ as_sf_list <- function(x, nm = "data", col = NULL, crs = NULL, clean_names = TRU
#' @param data Data that can be converted to sf, sfc, bbox or a sf list object.
#' @param class A class to convert data to; defaults to NULL (which returns
#' "sf")
#' @param null.ok For [as_sf_class], if class is `NULL` and null.ok is `TRUE`,
#' return x without any class conversion or checks. Defaults to `TRUE`.
#' @param ... Additional parameters passed to [as_sf], [as_sfc], [as_bbox], or
#' [as_sf_list]
#' @name as_sf_class
Expand Down
8 changes: 4 additions & 4 deletions R/count_features.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#' @param y Length 1 named `sf` list (name of y is used as count if count is
#' `NULL`) or a `sf` object if nm is not `NULL`. y must include a column name
#' matching the value of .id. If y is `NULL`, count is required. Default: `NULL`
#' @param nm Vector of names to use with [as_sf_list] to convert y to an sf list
#' (if y is not already an sf list). Defaults to "data".
#' @inheritParams st_join_ext
#' @inheritParams df_to_sf
#' @param count Name of column to count. If `NULL`, count is set to `names(y)`
Expand Down Expand Up @@ -46,9 +48,7 @@ count_features <- function(x = NULL,

x <- st_join_ext(x, y, join = join, .id = .id, ...)

if (is.null(count)) {
count <- names(y)
}
count <- count %||% names(y)

# Convert y back into a sf object
y <- as_sf(y)
Expand All @@ -70,7 +70,7 @@ count_features <- function(x = NULL,

geometry <- arg_match(geometry, c("y", "x", "drop"))

if (!is_sf(y) | (geometry == "x")) {
if (!is_sf(y) || (geometry == "x")) {
return(x)
}

Expand Down
11 changes: 11 additions & 0 deletions R/read_sf_ext.R
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ read_sf_rdata <- function(path,
#' @name read_sf_query
#' @rdname read_sf_ext
#' @inheritParams sf::read_sf
#' @param name,name_col Name value and name column to use in generated a query
#' for sources read with [read_sf_query] or [read_sf_esri]. This same
#' convention is used by [getdata::get_location] which wraps
#' sfext::read_sf_ext allowing the use of these parameters with any
#' [read_sf_ext] function. This option for filtering may be added to more
#' read_sf_ext functions in the future.
#' @param table table can usually be inferred from basename of the data source.
#' table is used to generate a custom query if both name and name_col are
#' provided. Use `sf::st_layers(dsn = dsn)[["name"]]` to see a list of
#' available table names.
#' @export
#' @importFrom stringr str_extract
#' @importFrom sf read_sf st_zm
Expand Down Expand Up @@ -482,6 +492,7 @@ read_sf_url <- function(url,

#' @name read_sf_esri
#' @rdname read_sf_ext
#' @inheritParams esri2sf::esri2sf
#' @export
read_sf_esri <- function(url,
bbox = NULL,
Expand Down
2 changes: 2 additions & 0 deletions R/utils-filename.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ str_remove_filetype <- function(string, filetype = NULL) {

#' @name str_extract_filetype
#' @rdname str_misc
#' @param tocase Function to use with [str_extract_filetype] for case conversion
#' of returned filetype. Defaults to [tolower()].
#' @export
str_extract_filetype <- function(string, filetype = NULL, tocase = tolower) {
filetype <- filetype %||% "[a-zA-Z0-9]+"
Expand Down
8 changes: 8 additions & 0 deletions man/as_sf.Rd

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

3 changes: 3 additions & 0 deletions man/count_features.Rd

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

17 changes: 14 additions & 3 deletions man/read_sf_ext.Rd

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

3 changes: 3 additions & 0 deletions man/str_misc.Rd

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

0 comments on commit bce07b6

Please sign in to comment.