Skip to contents

Several logical range comparison helpers

Usage

e1 %gele% e2

e1 %gel% e2

e1 %gle% e2

e1 %gl% e2

e1 %g% e2

e1 %ge% e2

e1 %l% e2

e1 %le% e2

e1 %!in% e2

e1 %nin% e2

e1 %flipIn% e2

e1 %grepl% e2

e1 %!grepl% e2

Arguments

e1

A number of vector to be evaluated

e2

A vector of one or two numbers used to denote the limits for logical comparison.

Value

A logical vector of the same length as e1.

Examples


1:5 %gele% c(2, 4)
#> [1] FALSE  TRUE  TRUE  TRUE FALSE
1:5 %gele% c(4, 2) # order does not matter uses min / max
#> [1] FALSE  TRUE  TRUE  TRUE FALSE

1:5 %gel% c(2, 4)
#> [1] FALSE  TRUE  TRUE FALSE FALSE
1:5 %gel% c(4, 2) # order does not matter uses min / max
#> [1] FALSE  TRUE  TRUE FALSE FALSE

1:5 %gle% c(2, 4)
#> [1] FALSE FALSE  TRUE  TRUE FALSE
1:5 %gle% c(4, 2) # order does not matter uses min / max
#> [1] FALSE FALSE  TRUE  TRUE FALSE

1:5 %gl% c(2, 4)
#> [1] FALSE FALSE  TRUE FALSE FALSE
1:5 %gl% c(4, 2) # order does not matter uses min / max
#> [1] FALSE FALSE  TRUE FALSE FALSE

1:5 %g% c(2)
#> [1] FALSE FALSE  TRUE  TRUE  TRUE

1:5 %ge% c(2)
#> [1] FALSE  TRUE  TRUE  TRUE  TRUE

1:5 %l% c(2)
#> [1]  TRUE FALSE FALSE FALSE FALSE

1:5 %le% c(2)
#> [1]  TRUE  TRUE FALSE FALSE FALSE

1:5 %!in% c(2, 99)
#> [1]  TRUE FALSE  TRUE  TRUE  TRUE
c("jack", "jill", "john", "jane") %!in% c("jill", "jane", "bill")
#> [1]  TRUE FALSE  TRUE FALSE

c("jack", "jill", "john", "jane", "sill", "ajay") %grepl% "ja"
#> [1]  TRUE FALSE FALSE  TRUE FALSE  TRUE
c("jack", "jill", "john", "jane", "sill", "ajay") %grepl% "^ja"
#> [1]  TRUE FALSE FALSE  TRUE FALSE FALSE

c("jack", "jill", "john", "jane", "sill", "ajay") %!grepl% "ja"
#> [1] FALSE  TRUE  TRUE FALSE  TRUE FALSE
c("jack", "jill", "john", "jane", "sill", "ajay") %!grepl% "^ja"
#> [1] FALSE  TRUE  TRUE FALSE  TRUE  TRUE