From 5fd340c119ab12e9072107a088ded19370dea142 Mon Sep 17 00:00:00 2001 From: SoyAndrea Date: Thu, 15 Aug 2024 14:09:00 -0700 Subject: [PATCH 1/2] Correct documentation for pmap Fixes #1124 --- R/pmap.R | 20 +++++++++++++++++++- man/pmap.Rd | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/R/pmap.R b/R/pmap.R index b3282eb7..da9cdf2f 100644 --- a/R/pmap.R +++ b/R/pmap.R @@ -23,7 +23,25 @@ #' * A formula, e.g. `~ ..1 + ..2 / ..3`. This syntax is not recommended as #' you can only refer to arguments by position. #' @inheritParams map -#' @inherit map return +#' @returns +#' The output length is determined by the length of the input. +#' The output names are determined by the names of the first element. +#' The output type is determined by the suffix: +#' +#' * No suffix: a list; `.f()` can return anything. +#' +#' * `_lgl()`, `_int()`, `_dbl()`, `_chr()` return a logical, integer, double, +#' or character vector respectively; `.f()` must return a compatible atomic +#' vector of length 1. +#' +#' * `_vec()` return an atomic or S3 vector, the same type that `.f` returns. +#' `.f` can return pretty much any type of vector, as long as its length 1. +#' +#' * `walk()` returns the input `.x` (invisibly). This makes it easy to +#' use in a pipe. The return value of `.f()` is ignored. +#' +#' Any errors thrown by `.f` will be wrapped in an error with class +#' [purrr_error_indexed]. #' @family map variants #' @export #' @examples diff --git a/man/pmap.Rd b/man/pmap.Rd index 7b1d872f..6cc99324 100644 --- a/man/pmap.Rd +++ b/man/pmap.Rd @@ -68,7 +68,7 @@ the desired type of output.} } \value{ The output length is determined by the length of the input. -The output names are determined by the input names. +The output names are determined by the names of the first element. The output type is determined by the suffix: \itemize{ \item No suffix: a list; \code{.f()} can return anything. From c1c42adb8bf0c069dabe61b437d604917d734cfa Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Tue, 20 Aug 2024 15:36:06 -0500 Subject: [PATCH 2/2] Document a few more differences --- R/pmap.R | 8 ++++---- man/pmap.Rd | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/R/pmap.R b/R/pmap.R index da9cdf2f..841818bc 100644 --- a/R/pmap.R +++ b/R/pmap.R @@ -24,8 +24,8 @@ #' you can only refer to arguments by position. #' @inheritParams map #' @returns -#' The output length is determined by the length of the input. -#' The output names are determined by the names of the first element. +#' The output length is determined by the maximum length of all elements of `.l`. +#' The output names are determined by the names of the first element of `.l`. #' The output type is determined by the suffix: #' #' * No suffix: a list; `.f()` can return anything. @@ -35,9 +35,9 @@ #' vector of length 1. #' #' * `_vec()` return an atomic or S3 vector, the same type that `.f` returns. -#' `.f` can return pretty much any type of vector, as long as its length 1. +#' `.f` can return pretty much any type of vector, as long as it is length 1. #' -#' * `walk()` returns the input `.x` (invisibly). This makes it easy to +#' * `pwalk()` returns the input `.l` (invisibly). This makes it easy to #' use in a pipe. The return value of `.f()` is ignored. #' #' Any errors thrown by `.f` will be wrapped in an error with class diff --git a/man/pmap.Rd b/man/pmap.Rd index 6cc99324..65babeef 100644 --- a/man/pmap.Rd +++ b/man/pmap.Rd @@ -67,8 +67,8 @@ of the elements of the result. Otherwise, supply a "prototype" giving the desired type of output.} } \value{ -The output length is determined by the length of the input. -The output names are determined by the names of the first element. +The output length is determined by the maximum length of all elements of \code{.l}. +The output names are determined by the names of the first element of \code{.l}. The output type is determined by the suffix: \itemize{ \item No suffix: a list; \code{.f()} can return anything. @@ -76,8 +76,8 @@ The output type is determined by the suffix: or character vector respectively; \code{.f()} must return a compatible atomic vector of length 1. \item \verb{_vec()} return an atomic or S3 vector, the same type that \code{.f} returns. -\code{.f} can return pretty much any type of vector, as long as its length 1. -\item \code{walk()} returns the input \code{.x} (invisibly). This makes it easy to +\code{.f} can return pretty much any type of vector, as long as it is length 1. +\item \code{pwalk()} returns the input \code{.l} (invisibly). This makes it easy to use in a pipe. The return value of \code{.f()} is ignored. }