Displaying 1 result from an estimated 1 matches for "testsize".
Did you mean:
test_size
2012 Nov 20
1
Removing columns that are na or constant
...ich 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 when I do my data sampling like so:
testSize <- floor(nrow(x) * 10/100)
test <- sample(1:nrow(x), testSize)
train_data <- x[-test,]
test_data <- x[test, -1]
test_class <- x[test, 1]
It is now possible that test_data or train_data contain columns that are constants, however as one dataset they did not.
So the solution for...