na_if_empty: Returns NA if an object handed to the function is empty

View source: R/utilities.R

na_if_emptyR Documentation

Returns NA if an object handed to the function is empty

Description

This is a helper function in defence against empty list items from iDAI.field 2 / Field Desktop, which sometimes occur. It simply writes NA in the corresponding field if a list or any kind of object handed to it is of length 0. Otherwise, it returns the input untouched.

Usage

na_if_empty(item)

Arguments

item

any object whatsoever

Value

NA if empty, or the object that has been handed to it

Examples

## Not run: 
na_if_empty(1)
na_if_empty(list(2,3,4,list(4,5,4)))
na_if_empty(NULL)

## End(Not run)

lsteinmann/idaifieldR documentation built on April 3, 2025, 2:06 p.m.