MyNixOS website logo
Description

Infix Operators for Detection, Subsetting and Replacement.

Infix operators to detect, subset, and replace the elements matched by a given condition. The functions have several variants of operator types, including subsets, ranges, regular expressions and others. Implemented operators work on vectors, matrices, and lists.

inops

Package implementing additional infix operators for R.

Implemented operators work with 4 different value types: sets, intervals, regular expressions, and counts.
And provide 3 distinct functionalities: detection, subsetting, and replacement.

inops_operator_table

For more examples please see the vignette.
For a complete list of available operators consult the tables below.

Syntax

All operators have the same form composed of two distinct parts: %<operation><type>%.

  • [operation] specifies the performed functionality and can be one of in, out, [in, [out.
  • [type] specifies the type of operation and can be one of {}, [], (), [), (], ~, ~p, ~f, #.

Detection Operators

FormDescriptionCall
%in{}%which elements are inside a setx %in{}% set
%in[]%which elements are inside a closed intervalx %in[]% interval
%in()%which elements are inside an open intervalx %in()% interval
%in[)%which elements are inside an interval open on the rightx %in[)% interval
%in(]%which elements are inside an interval open on the leftx %in(]% interval
%in~%which elements match a regular expressionx %in~% pattern
%in~p%which elements match a regular perl expressionx %in~p% pattern
%in~f%which elements match a regular fixed expressionx %in~f% pattern
%in#%which elements occur a specified number of timesx %in#% count
%out%which elements are outside a set (same as ! x %in% y)x %out% set
%out{}%which elements are outside a setx %out{}% set
%out[]%which elements are outside a closed intervalx %out[]% interval
%out()%which elements are outside an open intervalx %out()% interval
%out[)%which elements are outside an interval open on the rightx %out[)% interval
%out(]%which elements are outside an interval open on the leftx %out(]% interval
%out~%which elements do not match a regular expressionx %out~% pattern
%out~p%which elements do not match a regular perl expressionx %out~p% pattern
%out~f%which elements do not match a regular fixed expressionx %out~f% pattern
%out#%which elements occur other than a specified number of timesx %out#% count

Subsetting Operators

FormDescriptionCall
%[==%select elements equal to the provided valuex %[==% element
%[!=%select elements not equal to the provided valuex %[!=% element
%[>%select elements greater than the provided valuex %[>% number
%[<%select elements lower than the provided valuex %[<% number
%[>=%select elements greater or equal to the provided valuex %[>=% number
%[<=%select elements lower or equal to the provided valuex %[<=% number
%[in%select elements inside a setx %[in% set
%[in{}%select elements inside a setx %[in{}% set
%[in[]%select elements inside a closed intervalx %[in[]% interval
%[in()%select elements inside an open intervalx %[in()% interval
%[in[)%select elements inside an interval open on the rightx %[in[)% interval
%[in(]%select elements inside an interval open on the leftx %[in(]% interval
%[in~%select elements matching a regular expressionx %[in~% pattern
%[in~p%select elements matching a regular perl expressionx %[in~p% pattern
%[in~f%select elements matching a regular fixed expressionx %[in~f% pattern
%[in#%select elements that occur a specified number of timesx %[in#% count
%[out%select elements outside a setx %[out% set
%[out{}%select elements outside a setx %[out{}% set
%[out[]%select elements outside a closed intervalx %[out[]% interval
%[out()%select elements outside an open intervalx %[out()% interval
%[out[)%select elements outside an interval open on the rightx %[out[)% interval
%[out(]%select elements outside an interval open on the leftx %[out(]% interval
%[out~%select elements not matching a regular expressionx %[out~% pattern
%[out~p%select elements not matching a regular perl expressionx %[out~p% pattern
%[out~f%select elements not matching a regular fixed expressionx %[out~f% pattern
%[out#%select elements that occur other than specified number of timesx %[out% count

Replacement Operators

FormDescriptionCall
==<-change elements equal to the provided valuex == element <- value
!=<-change elements not equal to the provided valuex != element <- value
><-change elements greater than the provided valuex > number <- value
<<-change elements lower than the provided valuex < number <- value
>=<-change elements greater or equal to the provided valuex >= number <- value
<=<-change elements lower or equal to the provided valuex <= number <- value
%in%<-change elements inside a setx %in% set <- value
%in{}%<-change elements inside a setx %in{}% set <- value
%in[]%<-change elements inside a closed intervalx %in[]% interval <- value
%in()%<-change elements inside an open intervalx %in()% interval <- value
%in[)%<-change elements inside an interval open on the rightx %in[)% interval <- value
%in(]%<-change elements inside an interval open on the leftx %in(]% interval <- value
%in~%<-change elements matching a regular expressionx %in~% pattern <- value
%in~p%<-change elements matching a regular perl expressionx %in~p% pattern <- value
%in~f%<-change elements matching a regular fixed expressionx %in~f% pattern <- value
%in#%<-change elements that occur specified number of timesx %in#% count <- value
%out%<-change elements outside a setx %out% set <- value
%out{}%<-change elements outside a setx %out{}% set <- value
%out[]%<-change elements outside a closed intervalx %out[]% interval <- value
%out()%<-change elements outside an open intervalx %out()% interval <- value
%out[)%<-change elements outside an interval open on the rightx %out[)% interval <- value
%out(]%<-change elements outside an interval open on the leftx %out(]% interval <- value
%out~%<-change elements not matching a regular expressionx %out~% pattern <- value
%out~p%<-change elements not matching a regular perl expressionx %out~p% pattern <- value
%out~f%<-change elements not matching a regular fixed expressionx %out~f% pattern <- value
%out#%<-change elements that occur other than specified number of timesx %out#% count <- value

Notes

  1. Overloading

To give an assignment counterpart to < we had to overload the <<- operator, which explains the message when attaching the package. This doesn’t affect the behavior of the <<- assignments.

  1. Behaviour

Detection operators should be seen as an extension of the standard infix operators implemented in R (i.e. ==, >, etc). For this reason the implemented operators differ from standard %in% and behave more like == on data.frames and objects with NA values.

Subsetting and replacement operators are wrappers around detection operators.
Subsetting: x[ x %in{}% set].
Replacement: replace(x, x %in{}% set, value).

See Also

Other similar packages you might be interested in.

  1. intrval
  2. operators
  3. infix
  4. invctr
  5. grapes.
Metadata

Version

0.0.1

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