Learn R Programming

GROAN (version 1.3.1)

is.single.slot: Is a single slot thing?

Description

Checks if the passed variable is a single slot thing, meaning it contains only a single value (numeric, character, whatever) and nothing more. Works with array, vectors, matrix, data.frame...

Usage

is.single.slot(x, NULL.is.single = FALSE)

Value

TRUE if is single slot, FALSE otherwise

Arguments

x

the thing to be tested

NULL.is.single

should NULL be considered a single slot or not (default: not)

Examples

Run this code
is.single.slot(5)   #TRUE
is.single.slot('foobar')   #TRUE
is.single.slot(NULL)       #depends on NULL.is.single
is.single.slot(NA)         #TRUE
is.single.slot(c(1,2,5))   #FALSE
is.single.slot(matrix(0, 10, 5))   #FALSE
is.single.slot(matrix(0, 1, 1))   #TRUE

Run the code above in your browser using DataLab