Learn R Programming

toxboot (version 0.2.0)

listTonumeric: Convert x to numeric if x is a list.

Description

listTonumeric is used to convert x to a numeric type if x is a list.

Usage

listTonumeric(x)

Arguments

x

A list of length Y without NULL values.

Value

x a numeric vector of length Y.

Details

This function is used as part of reading data from mongoDB using rmongodb. Typically values will be stored as numeric vectors. However, if an NA is in the original vector, rmongodb will convert to NULL prior to writing to the database. This gets read from the database as a list of length Y rather than a numeric of length Y with positions that were NA now with value NULL. The function nullToNA converts the NULL values to NA, and this function converts the list back to a numeric type.

Examples

Run this code
# NOT RUN {
class(listTonumeric(list(1,2,3,4,NA,6,7)))
# }

Run the code above in your browser using DataLab