diff --git a/NEWS.md b/NEWS.md index 636668d4..2e286b62 100644 --- a/NEWS.md +++ b/NEWS.md @@ -744,7 +744,7 @@ accessor(x[[1]])$foo to the equivalent pluck: ``` -x %>% pluck(1, accessor, "foo") +x |> pluck(1, accessor, "foo") ``` @@ -968,7 +968,7 @@ This is a compatibility release with dplyr 0.6.0. * `set_names()` is a snake-case alternative to `setNames()` with stricter equality checking, and more convenient defaults for pipes: - `x %>% set_names()` is equivalent to `setNames(x, x)` (#119). + `x |> set_names()` is equivalent to `setNames(x, x)` (#119). ## Row based functionals @@ -980,7 +980,7 @@ functions. * `map()` now always returns a list. Data frame support has been moved to `map_df()` and `dmap()`. The latter supports sliced data frames as a shortcut for the combination of `by_slice()` and `dmap()`: - `x %>% by_slice(dmap, fun, .collate = "rows")`. The conditional + `x |> by_slice(dmap, fun, .collate = "rows")`. The conditional variants `dmap_at()` and `dmap_if()` also support sliced data frames and will recycle scalar results to the slice size. diff --git a/R/deprec-when.R b/R/deprec-when.R index 677c3ca7..a1fb6f04 100644 --- a/R/deprec-when.R +++ b/R/deprec-when.R @@ -36,7 +36,7 @@ #' #' @keywords internal #' @examples -#' 1:10 %>% +#' 1:10 |> #' when( #' sum(.) <= 50 ~ sum(.), #' sum(.) <= 100 ~ sum(.)/2, diff --git a/R/keep.R b/R/keep.R index ab217f59..e1df34cd 100644 --- a/R/keep.R +++ b/R/keep.R @@ -68,12 +68,12 @@ compact <- function(.x, .p = identity) { #' @export #' @examples #' x <- c(a = 1, b = 2, cat = 10, dog = 15, elephant = 5, e = 10) -#' x %>% keep_at(letters) -#' x %>% discard_at(letters) +#' x |> keep_at(letters) +#' x |> discard_at(letters) #' #' # Can also use a function -#' x %>% keep_at(~ nchar(.x) == 3) -#' x %>% discard_at(~ nchar(.x) == 3) +#' x |> keep_at(~ nchar(.x) == 3) +#' x |> discard_at(~ nchar(.x) == 3) keep_at <- function(x, at) { where <- where_at(x, at, user_env = caller_env()) x[where] diff --git a/README.Rmd b/README.Rmd index 1f11d9c0..dc6bc5e5 100644 --- a/README.Rmd +++ b/README.Rmd @@ -52,7 +52,7 @@ library(purrr) mtcars |> split(mtcars$cyl) |> # from base R map(\(df) lm(mpg ~ wt, data = df)) |> - map(summary) %>% + map(summary) |> map_dbl("r.squared") ``` diff --git a/README.md b/README.md index 7809a9e8..ed4d3cc8 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ library(purrr) mtcars |> split(mtcars$cyl) |> # from base R map(\(df) lm(mpg ~ wt, data = df)) |> - map(summary) %>% + map(summary) |> map_dbl("r.squared") #> 4 6 8 #> 0.5086326 0.4645102 0.4229655 diff --git a/man/keep_at.Rd b/man/keep_at.Rd index feff8223..3f025a98 100644 --- a/man/keep_at.Rd +++ b/man/keep_at.Rd @@ -25,12 +25,12 @@ Keep/discard elements based on their name/position } \examples{ x <- c(a = 1, b = 2, cat = 10, dog = 15, elephant = 5, e = 10) -x \%>\% keep_at(letters) -x \%>\% discard_at(letters) +x |> keep_at(letters) +x |> discard_at(letters) # Can also use a function -x \%>\% keep_at(~ nchar(.x) == 3) -x \%>\% discard_at(~ nchar(.x) == 3) +x |> keep_at(~ nchar(.x) == 3) +x |> discard_at(~ nchar(.x) == 3) } \seealso{ \code{\link[=keep]{keep()}}/\code{\link[=discard]{discard()}} to keep/discard elements by value. diff --git a/man/when.Rd b/man/when.Rd index ff3c85a5..d7815456 100644 --- a/man/when.Rd +++ b/man/when.Rd @@ -37,7 +37,7 @@ valid match/condition is found the action is executed and the result of the action is returned. } \examples{ -1:10 \%>\% +1:10 |> when( sum(.) <= 50 ~ sum(.), sum(.) <= 100 ~ sum(.)/2, diff --git a/purrr.Rproj b/purrr.Rproj index 69b10ac6..cba1b6b7 100644 --- a/purrr.Rproj +++ b/purrr.Rproj @@ -19,5 +19,3 @@ BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source PackageRoxygenize: rd,collate,namespace - -UseNativePipeOperator: Yes diff --git a/vignettes/base.Rmd b/vignettes/base.Rmd index 3b37d290..9f13787c 100644 --- a/vignettes/base.Rmd +++ b/vignettes/base.Rmd @@ -281,9 +281,9 @@ The pipe is particularly compelling when working with longer transformations. For example, the following code splits `mtcars` up by `cyl`, fits a linear model, extracts the coefficients, and extracts the first one (the intercept). ```{r, eval = modern_r} -mtcars %>% - split(mtcars$cyl) %>% - map(\(df) lm(mpg ~ wt, data = df)) %>% - map(coef) %>% +mtcars |> + split(mtcars$cyl) |> + map(\(df) lm(mpg ~ wt, data = df))|> + map(coef) |> map_dbl(1) ``` diff --git a/vignettes/other-langs.Rmd b/vignettes/other-langs.Rmd index dc1df51c..dd51b534 100644 --- a/vignettes/other-langs.Rmd +++ b/vignettes/other-langs.Rmd @@ -23,7 +23,7 @@ purrr draws inspiration from many related tools: However, the goal of purrr is not to try and simulate a purer functional programming language in R; we don't want to implement a second-class version of Haskell in R. The goal is to give you similar expressiveness to an FP language, while allowing you to write code that looks and works like R: -* Instead of point free (tacit) style, we use the pipe, `%>%`, to write code +* Instead of point free (tacit) style, we use the pipe, `|>`, to write code that can be read from left to right. * Instead of currying, we use `...` to pass in extra arguments.