Divide data set into 60%, 20%, 20%

Viewed 1486

I am trying to move from 2 sets of data to 3 sets as explained in the above question. Following is the script I used:

set.seed(125)
d <- sample(x = nrow(db), size = nrow(db) * 0.60, )
train60 <-db[d, ]
valid40 <-db[-d, ]

Is there a way to modify the above script? I have tried to create another line:

valid40 <- db[-d] * 0.2 which did not work.

Current dataset has several factor variables.

I have tried using Frank's solution here on the cut function, but somehow I manage to get

Error in cut.default(seq(nrow(df)), nrow(df) * cumsum(c(0, spec)), labels = names(spec)) : lengths of 'breaks' and 'labels' differ

which I don't understand even after searching for help online.

2 Answers
Related