[R] Removing columns that are na or constant

2012-11-20 Thread Brian Feeny
I have a dataset that has many columns which are NA or constant, and so I remove them like so: same - sapply(dataset, function(.col){ all(is.na(.col)) || all(.col[1L] == .col) }) dataset - dataset[!same] This works GREAT (thanks to the r-users list archive I found this) however, then

Re: [R] Removing columns that are na or constant

2012-11-20 Thread Rui Barradas
Hello, Inline. Em 20-11-2012 22:03, Brian Feeny escreveu: I have a dataset that has many columns which are NA or constant, and so I remove them like so: same - sapply(dataset, function(.col){ all(is.na(.col)) || all(.col[1L] == .col) }) dataset - dataset[!same] This works GREAT (thanks