title: R语言:数据集分割 tags: [] id: '1991' categories:
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)