https://github.com/ebeneditos/infix
Basic Infix Binary Operators
https://github.com/ebeneditos/infix
cran infix operators package r
Last synced: 3 months ago
JSON representation
Basic Infix Binary Operators
- Host: GitHub
- URL: https://github.com/ebeneditos/infix
- Owner: ebeneditos
- License: gpl-3.0
- Created: 2018-12-07T19:01:17.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-15T20:37:13.000Z (over 5 years ago)
- Last Synced: 2024-02-09T02:17:46.486Z (over 1 year ago)
- Topics: cran, infix, operators, package, r
- Language: R
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# infix
> Basic Infix Binary Operators
[](https://cran.r-project.org/package=infix)
[](https://www.r-pkg.org/pkg/infix)
[](https://travis-ci.org/ebeneditos/infix)
[](https://ci.appveyor.com/project/ebeneditos/infix)
[](https://codecov.io/gh/ebeneditos/infix)
[](https://www.gnu.org/licenses/gpl-3.0.html)Contains a number of infix binary operators that may be useful in day to day practices.
## Installation
You can install `infix` from CRAN:
``` r
install.packages("infix")
```Or the development version from GitHub:
``` r
# 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:
```r
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.