Class of data.table column

后端 未结 1 1872
伪装坚强ぢ
伪装坚强ぢ 2020-12-11 16:08

I\'d like to know how to ascertain the class of a column in a data.table dt given a character vector w.

Reproducible example:



        
相关标签:
1条回答
  • 2020-12-11 16:49

    These seem to work in the way you want:

    1. class(dt[[w]])
    2. sapply(dt,class)

    Also, doing 2 and then subsetting works for 1: sapply(dt,class)[w].

    0 讨论(0)
提交回复
热议问题