In your loop, you overwrite both testframe
and trainframe
in each run of the loop. You could use testframe <- rbind(testframe, utilities[i, ])
, but this would be quite inefficient.
Here's another approach without loops:
x <- sample(c(TRUE, FALSE), 117, replace = TRUE)
testframe <- utilities[x, ]
trainframe <- utilities[!x, ]
You can also create a list including the two subsets (based on vector x
):
split(utilities, x)