【发布时间】:2016-05-29 00:12:00
【问题描述】:
我创建了一个向量如下
Expenditure
[1] 13.9 15.4 15.8 17.9 18.3 19.9 20.6 21.4 21.7 23.1
[11] 20.0 20.6 24.0 25.1 26.2 30.0 30.6 30.9 33.8 44.1
现在我从Expenditure随机抽取了10个样本
ransomsample <- sample(Expenditure,10)
ransomsample
[1] 19.9 21.4 20.0 30.0 17.9 25.1
[7] 26.2 21.7 33.8 13.9
现在我想在创建名为ransomsample 的样本后找到Expenditure 中的剩余项目。我可以使用任何现有的功能吗?
【问题讨论】:
-
有解决问题的方法吗?
-
看看
help("%in%") -
最终你可以通过构造一个逻辑索引向量
i <- sample(c(TRUE, FALSE), length(Expenditure), repl=TRUE)来进行采样
标签: r vector random-sample