📜  如何在 r 中拆分训练和测试数据 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:51.135000             🧑  作者: Mango

代码示例1
library(caTools)
sample <- sample.split(data$y, SplitRatio = 0.7)
train_data <- subset(data, sample == TRUE)
test_data <- subset(data, sample == FALSE)