checkDT {R2DT} | R Documentation |
Checking if an object is a data.table object and (optional) testing if some column names are valid for it
checkDT(inputDT, colNamesToBeChecked = NULL)
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. |
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).
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')) checkDT(inputDT, c('x', 'y1')) checkDT(inputDT, c('x', 'y1', 'z1')) checkDT(inputDT, c('x1', 'y1', 'z1'))