Some machine learning techniques require three partitions, because they use two partitions just for building the model. Thus, the third (test) partition contains the hold out data for model evaluation.
Suppose we want a training partition with 70 percent of the cases, and the rest divided equally among validation and test partitions. We then use the following commands:
> trg.idx <- createDataPartition(bh$MEDV, p = 0.7, list = FALSE) > trg.part <- bh[trg.idx, ] > temp <- bh[-trg.idx, ] > val.idx <- createDataPartition(temp$MEDV, p = 0.5, list = FALSE) > val.part <- temp[val.idx, ] > test.part <- temp[-val.idx, ]