Select mutilple columns in data.table

 

dt is a data.table with multiple columns (variables), if we want to select many columns in one go, we could do this:dt[, columnA:columnD].

Also, we could delete multiple columns with -or !:dt[, -(columnA:columnD)]dt[, !(columnA:columnD), note that the column names should be in brackets ()

posted @ 2022-06-26 15:52  DaqianLU  阅读(23)  评论(0)    收藏  举报