This function splits the input data and response variables into training and testing parts.
split_data(X, y, p.train = 0.7, n.train = round(nrow(X) * p.train))
X | Input matrix, of dimension |
---|---|
y | Vector of response variables. |
p.train | Percentage of training set. |
n.train | Number of cases for training; will override |
List of training data x.tr
, y.tr
and testing data x.te
, y.te
.
#> [1] 70 10#> [1] 30 10