SplitRatio results with sample.split (caTools)

我的未来我决定 提交于 2021-02-11 09:59:19

问题


The SplitRatio argument does not behave like I would expect it to.

For example, if the SplitRatio is 0.5, I would expect 50% TRUE and 50% FALSE assignments.

However, when running the code below on a vector of length 20 I would expect 10 TRUE assignment but I frequently get results like 13 or 14.

Why is that?

vec <- sample(1:10, 20, replace = TRUE)
length(vec)
split <- sample.split(vec, SplitRatio = 0.5)
vec.split <- subset(vec, split == TRUE)
length(vec.split)
[1] 13

来源:https://stackoverflow.com/questions/57137152/splitratio-results-with-sample-split-catools

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!