Learn R Programming

toxboot (version 0.2.0)

nullToNA: Replace NULL values with NA.

Description

nullToNA is used to convert any NULL values to NA in a list.

Usage

nullToNA(x)

Arguments

x

A list.

Value

x with all NULL at the top level of the list replaced by NA.

Details

This function is used when reading vectors from mongoDB. If the original vector had a value of NA, rmongodb converts to NULL before writing to the database. When rmongodb performs a find, these NULL values are left as NULL, and when unlisted will shorten the vector. Before unlisting the vector, this function is run to convert the NULL values to NA so that the vector remains the correct length and that NAs are in the correct positions.

Examples

Run this code
# NOT RUN {
nullToNA(list(1,5,'a', NULL, NA, 4))
# }

Run the code above in your browser using DataLab