MyNixOS website logo
Description

Extra Binary Relational and Logical Operators.

Speed up common tasks, particularly logical or relational comparisons and routine follow up tasks such as finding the indices and subsetting. Inspired by mathematics, where something like: 3 < x < 6 is a standard, elegant and clear way to assert that x is both greater than 3 and less than 6 (see for example <https://en.wikipedia.org/wiki/Relational_operator>), a chaining operator is implemented. The chaining operator, %c%, allows multiple relational operations to be used in quotes on the right hand side for the same object, on the left hand side. The %e% operator allows something like set-builder notation (see for example <https://en.wikipedia.org/wiki/Set-builder_notation>) to be used on the right hand side. All operators have built in prefixes defined for all, subset, and which to reduce the amount of code needed for common tasks, such as return those values that are true.

extraoperators

CRAN_status R-CMD-check codecov lifecycle

An R package with operators to help speed up everyday tasks.

Installation

To get the latest development version, use:

#install.packages("devtools")
devtools::install_github("JWiley/extraoperators")

Otherwise to get from CRAN use:

install.packages("extraoperators")

Overview

The table below summarizes what this package provides. Fundamentally it provides or expands on 14 different logical operators, which can be accessed on their own to return a logical vector, but also prefixed by ? (which) to return the indices that are TRUE or prefixed by s (subset) to return only those values that are TRUE or prefixed by a (all) to return a single logical value, are ALL true? An entire all logical comparison can be prefixed by ! to generate a NONE evaluation.

OperatorWhat it doesWhich?SubsetAll
==Are values / vectors equal%?==%%s==%%a==%
!=Are values / vector NOT equal%?!=%%s!=%%a!=%
%l%Less than%?l%%sl%%al%
%le%Less than or equal%?le%%sle%%ale%
%g%Greater than%?g%%sg%%ag%
%ge%Greater than or equal%?ge%%sge%%age%
%gl%Greater than AND less than%?gl%%sgl%%agl%
%gel%Greater than or equal AND less than%?gel%%sgel%%agel%
%gle%Greater than AND less than or equal%?gle%%sgle%%agle%
%gele%Greater than or equal AND less than or equal%?gele%%sgele%%agele%
%in%In%?in%%sin%%ain%
%!in% OR %nin%Not in%?!in% OR %?nin%%s!in% OR %snin%%a!in% OR %anin%
%c%Chain operations on the RHS together%?c%%sc%%ac%
%e%Set operator, to use set notation%?e%%se%%ae%
%grepl%does text match a regular expression%?grepl%%sgrepl%%agrepl%
%!grepl%does text NOT match a regular expression%?!grepl%%s!grepl%%a!grepl%

Using these operators, you can accomplish many different tasks by just remembering the additional prefixes: ? for which(), a for all() and s for subset(). While simple, this can save quite a few keystrokes and make various logical comparisons less convoluted.

Metadata

Version

0.3.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows