Advanced R Pipes

Provides convenience functions for programming with 'magrittr' pipes. Conditional pipes, a string prefixer and a function to pipe the given object into a specific argument given by character name are currently supported. It is named after the dadaist Hans Arp, a friend of Rene Magritte.


arpr

R-CMD-check

The goal of arpr is to provide convenience functions for programming with magrittr pipes. Conditional pipes, a string prefixer and a function to pipe the given object into a specific argument given by character name are currently supported. It is named after the dadaist Hans Arp, a friend of Rene Magritte.

Note that the {arpr} package was originally created by Jirka Lewandowski. The present repository is a fork to be able to continue development of this package, required for {gitlabr}.

Installation

You can install the released version of arpr from CRAN with:

install.packages("arpr")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("statnmap/arpr")

Examples

library(arpr)
  • Prefix a string of text
"xyz" %>%
   prefix("abc")
#> [1] "abcxyz"
  • iff() applies a function if and only if test is TRUE
    • otherwise return input value unchanged
    • iffn() is if and only if test is FALSE
x <- 1
x %>%
  iff(is.na, const(0))
#> [1] 1
x <- NA
x %>%
  iff(is.na, const(0))
#> [1] 0

x <- 1
x %>%
  iff(x <= 0, function(x) { x - 2 })
#> [1] 1
x <- -1
x %>%
  iff(x <= 0, function(x) { x - 2 })
#> [1] -3

x <- NA
x %>%
  iffn(is.na, exp)
#> [1] NA
x <- 10
x %>%
  iffn(is.na, exp)
#> [1] 22026.47
  • Pipe into specific formal argument
5L %>%
  pipe_into("digits", format, 2.731234567)
#> [1] "2.7312"

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("arpr")

0.1.2 by Sébastien Rochette, 5 years ago


https://github.com/statnmap/arpr


Report a bug at https://github.com/statnmap/arpr/issues


Browse source code at https://github.com/cran/arpr


Authors: Jirka Lewandowski [aut] , Sébastien Rochette [aut, cre]


Documentation:   PDF Manual  


GPL (>= 3) license


Imports magrittr, rlang

Suggests testthat


Imported by gitlabr.


See at CRAN