Convert classes of a data.table:

setColumnClasses(DT, classes = NULL)

Arguments

DT

A data.table

classes

A named list of classes. Columns in DT with name found in classes are modified if the existing class differs from the desired class.