Reputation: 177
I have randomly generated a submatrix “train” from “mat” using the following:
train <- mat[sample(nrow(mat), size = 317, replace = FALSE),]
My question is, how do I then create “test” as a submatrix of “mat” which excludes the matrix “train”?
Thanks!
Upvotes: 2
Views: 41
Reputation: 251
train.index
are the indexes used for training.
mat <- matrix(rnorm(20000),nrow=1000)
train.index <-sample(nrow(mat), size = 317, replace = FALSE)
train <- mat[train.index,]
test <- mat[-train.index,]
Upvotes: 1