Basic Infix Binary Operators

Contains a number of infix binary operators that may be useful in day to day practices.


CRAN Travis CI Status AppVeyor build status Codecov

Contains a number of infix binary operators that may be useful in day to day practices.

Installation

You can install infix from CRAN:

install.packages("infix")

Or the development version from GitHub:

# install.packages("devtools")
devtools::install_github("ebeneditos/infix")

Usage

You can find a full list of operators running ?infix, but here there are a few examples:

library(infix)
 
# tryExcept (%except%)
{foo <- "foo"} %except% {foo <- "foo bar"}
print(foo) # "foo"
 
{ foo <- "foo"
  stop()
} %except% {
  foo <- "foo bar"
}
print(foo) # "foo bar"
 
# paste0 (%+%)
"01" %+% "jan" %+% "1970" # returns "01jan1970"
 
# file.path (%//%)
"home" %//% "dir" # returns "home/dir"
 
# nomatch (%!in%)
4 %!in% 1:3 # returns TRUE
 
# nil (%||%)
1 %||% 2 # returns 1
NULL %||% 2 # returns 2
 
# functions logic (%&%, %|% and %xor%)
is.null.na <- is.null %|% is.na
all(is.null.na(NA), is.null.na(NULL)) # returns TRUE

Also, magrittr pipe-operators (such as %>%) are imported.

News

v0.1.0

  • First release on CRAN.

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("infix")

0.1.0 by Ernest Benedito, 4 months ago


http://github.com/ebeneditos/infix


Report a bug at http://github.com/ebeneditos/infix/issues


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


Authors: Ernest Benedito [aut, cre]


Documentation:   PDF Manual  


GPL-3 license


Imports magrittr

Suggests covr, testthat


See at CRAN