小白求教大神
是这样的,我有7376条数据,因为太多所以需要分层抽样。
构思是按照序号由小到大每六个为一组进行随机抽样。
为了简化数据,我制作了只包含顺序和分组信息的txt。截图如下
按照教程,这是我写的代码
library(sampling)
library(data.table)
sampling <- as.matrix(fread("sampling.txt",header = TRUE,sep = "\t",encoding = "UTF-8"))
n=round(nrow(sampling)/6)
strata.1 <- strata(data = sampling,stratanames=sampling[,2],size=rep(n,6),method=srswor)
结果系统报错
Error in match(x, table, nomatch = 0L) :
'match' requires vector arguments
后来用as.vector进行了数据变换还是不行。
求教各位大神,不胜感激