R语言:数据集分割

发布于 2022-08-19  82 次阅读


安装补充包

划分训练集和验证集

library("caTools")
dat <- readRDS('../data/dat.rds')
set.seed(123)
split = sample.split(substr(rownames(dat),1,2),SplitRatio = .8)
train_data = subset(dat, split == TRUE)
test_data  = subset(dat, split == FALSE)

医学生