insiders: Inside interval

insidersR Documentation

Inside interval

Description

Decide if a value x falls inside an interval j[1],j[2] that can be open or closed on the left and/or the right. Either a logical vector equal to x, or the actual values are extracted, when the '.'-versions are used.

Usage

x %[]% j

x %()% j

x %[)% j

x %(]% j

x %[.]% j

x %(.)% j

x %[.)% j

x %(.]% j

Arguments

x

A vector

j

A 2-element numeric vector indicating a range

Value

Logical vector of length x, or, values in the range j

Note

Package 'DescTools' provides similar functions

Examples


# Closed interval
0:5 %[]% c(1,5)  # logical vector
0:5 %[.]% c(1,5) # extract values

# Open interval
0:5 %()% c(1,5)
0:5 %(.)% c(1,5)

# Closed interval left
0:5 %[)% c(1,5)
0:5 %[.)% c(1,5)

# Closed interval right
0:5 %(]% c(1,5)
0:5 %(.]% c(1,5)



invctr documentation built on Aug. 16, 2022, 5:18 p.m.