I have a data.table with some columns contain NAs only. I want to remove these columns.
I tried this, but doesn't seem to work for data.table class.
edit:
library('data.table')
dat = data.table(a = rep(NA, 10), b = 1:10)
dat
a b
1: NA 1
2: NA 2
3: NA 3
4: NA 4
5: NA 5
6: NA 6
7: NA 7
8: NA 8
9: NA 9
10: NA 10
dat[, ( colSums(is.na(dat)) != nrow(dat) ) := NULL]
Error in
[.data.table
(dat, ,:=
((colSums(is.na(dat)) != nrow(dat)), : LHS of := isn't column names ('character') or positions ('integer' or 'numeric')