Skip to contents

is_ functions returns a boolean, given a condition.

is_blank

The goal of is_blank is to check if a value is blank.


is_blank("")
#> [1] TRUE

is_blank(NA_character_)
#> [1] TRUE

is_blank(" ")
#> [1] TRUE

is_blank("-")
#> [1] TRUE

is_blank(NULL)
#> [1] TRUE

is_blank(NaN)
#> [1] TRUE

is_date

The goal of is_date is to check if a value is a date.

is_date(Sys.time())
#> [1] FALSE

is_date(Sys.Date())
#> [1] TRUE

is_datetime

The goal of is_datetime is to check if a value is a datetime.

is_datetime(Sys.time())
#> [1] TRUE

is_datetime(Sys.Date())
#> [1] FALSE

is_even

The goal of is_even is to check if a value is even.

is_even(1)
#> [1] FALSE

is_even(2)
#> [1] TRUE

is_even(1.1)
#> [1] FALSE

is_even(2.2)
#> [1] TRUE

is_integer

The goal of is_integer is to check if a value is a integer, not considering their variable type but the value.

is_integer(1.1)
#> [1] FALSE

is_integer(1)
#> [1] TRUE

is_negative

The goal of is_negative is to check if a value is negative.

is_negative(1)
#> [1] FALSE

is_negative(-1)
#> [1] TRUE

is_odd

The goal of is_odd is to check if a value is odd.

is_odd(1)
#> [1] TRUE

is_odd(2)
#> [1] FALSE

is_odd(1.1)
#> [1] TRUE

is_odd(2.2)
#> [1] FALSE

is_outlier

The goal of is_outlier is to check if a value is an outlier, by using the boxplot outlier criteria, given by:

\[ [x < (Q_1 - 1.5 * IQR)] \quad | \quad [x > (Q_3 - 1.5 * IQR)],\]

where:

  • \(Q_1\) is the first quartile;
  • \(Q_3\) is the third quartile;
  • \(IQR\) is the interquartile range, e.g., \(Q_3-Q_1\).
x <- c(1,2,3,5,7,8,12,100)

is_outlier(x)
#> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE

is_positive

The goal of is_positive is to check if a value is positive.

is_positive(1)
#> [1] TRUE

is_positive(-1)
#> [1] FALSE

is_string

The goal of is_string is to check if a value is a string, character or factor.

is_string("A")
#> [1] TRUE

is_string(factor("A"))
#> [1] TRUE

is_weekend

The goal of is_weekend is to check if a date variable is in a weekend (saturday/sunday).

is_weekend(Sys.time())
#> [1] FALSE

is_weekend(Sys.Date())
#> [1] FALSE

is_zero

The goal of is_zero is to check if a value is equal to zero.

is_zero(1)
#> [1] FALSE

is_zero(0)
#> [1] TRUE