Learn R Programming

R2DT (version 0.2)

checkDT: Checking if an object is a data.table object and (optional) testing if some column names are valid for it

Description

Checking if an object is a data.table object and (optional) testing if some column names are valid for it

Usage

checkDT(inputDT, colNamesToBeChecked = NULL)

Arguments

inputDT

data.table object containing the data of interest. This is an obligatory argument, without default value.

colNamesToBeChecked

Character vector containing potential column names of the 'inputDT' argument. The default value is NULL.

Value

No value is returned if all elements in the 'colNamesToBeChecked' argument, are valid column names of the 'inputDT' argument. In the absence of a value for the 'colNamesToBeChecked' argument, it is only tested if the 'inputDT' argument is a data.table object (is tested irrespective of the value for the 'colNamesToBeChecked' argument).

Examples

Run this code
# NOT RUN {
library(data.table)
inputDT <- as.data.table(data.frame(x = seq(1, 20, 2), y = LETTERS[1:10]))
asFactorDT(inputDT, c('y'))

checkDT(inputDT)
checkDT(inputDT, c('x', 'y'))

# }
# NOT RUN {
checkDT(inputDT, c('x', 'y1'))
checkDT(inputDT, c('x', 'y1', 'z1'))
checkDT(inputDT, c('x1', 'y1', 'z1'))
# }

Run the code above in your browser using DataLab