in: Inside Subset

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Operators for checking if value is within a given interval or subset.

Usage

1
2
3
4
5
6
7
8
9
x %in{}% subset

x %in[]% interval

x %in()% interval

x %in(]% interval

x %in[)% interval

Arguments

x

vector or array of values to be matched.

subset

vector or list of values to be matched against.

interval

vector with two elements defining an interval range.

Details

Parenthesss of each operator define how the subset is specified:
%in{}% - lists all elements of the subset
%in[]% - subset specified as an closed interval
%in()% - subset specified as a open interval
%in(]% - interval that is open on the left and closed on the right
%in[)% - interval that is closed on the left and open on the right

The %in{}% operator is a reimplementation of %in% that preserves the dimensions of x (see examples).

The operations using intervals are a convenient short hand for
x > interval[1] & x < interval[2].

The idea for function names is taken from the package DescTools by Andri Signorell.

Value

a logical vector or an array of the same dimensions as x indicating if each value of x is within the defined subset.

Author(s)

Karolis Koncevičius

See Also

%in%, %out%, %[]%

Examples

1
2
3
4
5
  c("a", "b", "Z") %in{}% letters

  iris %in{}% "setosa"

  1:10 %in(]% c(2,5)

KKPMW/infixer documentation built on May 7, 2019, 6:04 a.m.