Skip to content

Commit

Permalink
Update tidyverse docs
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Feb 15, 2024
1 parent 515dbec commit b9a3910
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 88 deletions.
67 changes: 22 additions & 45 deletions R/tidyverse.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## dplyr methods:
## dplyr methods: ------
#group_map.sf <- function(.tbl, .f, ...) {
# st_as_sf(NextMethod()) # nocov
#}
Expand Down Expand Up @@ -375,7 +375,7 @@ distinct.sf <- function(.data, ..., .keep_all = FALSE) {
}
}

## tidyr methods:
## tidyr methods: --------

#' @name tidyverse
#' @param data see original function docs
Expand Down Expand Up @@ -404,20 +404,11 @@ gather.sf <- function(data, key, value, ..., na.rm = FALSE, convert = FALSE, fac
sf_column_name = attr(data, "sf_column"))
}

#' @name tidyverse
#' @rdname tidyverse
#' @param data see original function docs
#' @param cols see original function docs
#' @param names_to see original function docs
#' @param names_prefix see original function docs
#' @param names_sep see original function docs
#' @param names_pattern see original function docs
#' @param names_ptypes see original function docs
#' @param names_transform see original function docs
#' @param names_repair see original function docs
#' @param values_to see original function docs
#' @param values_drop_na see original function docs
#' @param values_ptypes see original function docs
#' @param values_transform see original function docs
#' @param names_to,names_prefix,names_sep,names_pattern,names_ptype,names_transform,names_repair see [tidyr::pivot_longer()]
#' @param values_to,values_drop_na,value_ptypes,values_transform See [tidyr::pivot_longer()]
pivot_longer.sf <- function (data, cols, names_to = "name", names_prefix = NULL,
names_sep = NULL, names_pattern = NULL, names_ptypes = NULL,
names_transform = NULL, names_repair = "check_unique",
Expand Down Expand Up @@ -452,23 +443,12 @@ pivot_longer.sf <- function (data, cols, names_to = "name", names_prefix = NULL,
st_as_sf(out, sf_column_name = sf_column_name)
}

globalVariables(c("name", "value"))
utils::globalVariables(c("name", "value"))
# https://github.com/r-spatial/sf/issues/1915
#' @name tidyverse
#' @export
#' @param id_cols see original function docs
#' @param id_expand see original function docs
#' @param names_from see original function docs
#' @param names_prefix see original function docs
#' @param names_sep see original function docs
#' @param names_glue see original function docs
#' @param names_sort see original function docs
#' @param names_vary see original function docs
#' @param names_expand see original function docs
#' @param names_repair see original function docs
#' @param values_from see original function docs
#' @param values_fill see original function docs
#' @param values_fn see original function docs
#' @rdname tidyverse
#' @param id_cols,id_expand see [tidyr::pivot_wider()]
#' @param names_from,names_prefix,names_sep,names_glue,names_sort,names_wary,names_repair see [tidyr::pivot_wider()].
#' @param values_from,values_fill,values_fn see [tidyr::pivot_wider()]
#' @param unused_fn see original function docs
pivot_wider.sf = function(data,
...,
Expand Down Expand Up @@ -644,12 +624,19 @@ unnest.sf = function(data, ..., .preserve = NULL) {
# nocov end
}

## tibble methods:
#' @name tidyverse
drop_na.sf <- function(x, ...) {
sf_column_name = attr(x, "sf_column")
class(x) <- setdiff(class(x), "sf")
st_as_sf(NextMethod(), sf_column_name = sf_column_name)
}

## tibble methods: -------

#' Summarize simple feature type for tibble
#'
#' Summarize simple feature type for tibble
#' @param x object of class sfc
#' Summarize simple feature type / item for tibble
#' @param x object of class `sfc`
#' @param ... ignored
#' @name tibble
#' @details see \link[pillar]{type_sum}
Expand All @@ -661,15 +648,12 @@ type_sum.sfc <- function(x, ...) {
cls
}

#' Summarize simple feature item for tibble
#'
#' Summarize simple feature item for tibble
#' @name tibble
#' @rdname tibble
obj_sum.sfc <- function(x) {
vapply(x, function(sfg) format(sfg, width = 15L), "")
}

#' @name tibble
#' @rdname tibble
pillar_shaft.sfc <- function(x, ...) {
digits = options("pillar.sigfig")$pillar.sigfig
if (is.null(digits))
Expand All @@ -680,13 +664,6 @@ pillar_shaft.sfc <- function(x, ...) {
pillar::new_pillar_shaft_simple(out, align = "right", min_width = 25)
}

#' @name tidyverse
drop_na.sf <- function(x, ...) {
sf_column_name = attr(x, "sf_column")
class(x) <- setdiff(class(x), "sf")
st_as_sf(NextMethod(), sf_column_name = sf_column_name)
}

#nocov start
register_all_s3_methods = function() {
has_dplyr_1.0 =
Expand Down
6 changes: 2 additions & 4 deletions man/tibble.Rd

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

47 changes: 8 additions & 39 deletions man/tidyverse.Rd

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

0 comments on commit b9a3910

Please sign in to comment.