lambda.tools (version 1.0.9)

is.empty: Check whether data is bad or empty

Description

These functions quickly test whether data within an object has bad values or if the object is defined (i.e. not null) but has no data.

Arguments

x
An object containing the data to test

Value

Logical values that indicate whether the test was successful or not. For matrices and data.frames, a matrix of logical values will be returned.

Usage

is.empty(x) is.empty(x) is.bad(x)

Details

Depending on the type of an object, knowing whether an object contains a valid value or not is different. These functions unify the interfaces across different data types quickly indicating whether an object contains bad values and also whether an object has a value set. For example, a data.frame may be initialized with no data. This results in an object that is non-null but also unusable. Instead of checking whether something is both non-null and has positive length, just check is.bad(). If you know that an object is non-null, then you can call is.empty() which is a shortcut for checking the length of an object.

Examples

Run this code
a <- data.frame(a=NULL, b=NULL)
is.bad(a)

b <- list(a=1:3, b=NULL, c=NA, d='foo')
is.bad(b)

c <- list()
is.empty(c)

Run the code above in your browser using DataCamp Workspace