从大小为 200 的原始数据集中进行替换抽样。计算每个值的频率并将零分配给未出现的值。将过程迭代 10 次并将结果存储在 Matrix 中。
问问题
68 次
1 回答
0
你没有提供太多背景,所以这是我的解释:
## You didn't specify what we were sampling from, so I just took it as all numbers from 1 to 200
x <- 1:200
## Sampled from x in sizes of 50 (because you didn't specify how big), with replacement, 10 times
samp <- list()
for (i in 1:10){
samp[[i]] <- sample(x, size = 50, replace = TRUE)
}
results <- list()
results.mat <- 1:200
for (i in 1:10){
results[[i]] <- table(factor(samp[[i]], levels = 1:200))
results.mat <- cbind(results.mat, results[[i]])
}
View(results.mat)
于 2013-07-18T13:32:16.973 回答