Convert classes of a data.table:

setColumnClasses(DT, classes = NULL)

Arguments

DT

A data.table

classes

A list of classes named by the columns for which the class should be set. Columns in DT with name found in the names of classes are modified if the existing class differs from the desired class.