Displaying 4 results from an estimated 4 matches for "expandsingle".
2015 Jun 17
1
Add-on argument in sample()
> Then the question would be if this test could be replaced with a new
> argument to sample, e.g. expandSingle, which has TRUE as default for
> backward compatibility, but FALSE if you dont want population to be
> expanded to 1:population. It could certainly be useful in some cases,
> but you still need to know about the expansion to use it. I think most
> of these bugs occur because users d...
2015 Jun 17
2
Add-on argument in sample()
...cial case:
if (length(population) == 1 & size == 1) {
population
} else if (!replace & length(population) >= size) {
sample(population, size = size, replace = replace)
} else {
...
}
Then the question would be if this test could be replaced with a new
argument to sample, e.g. expandSingle, which has TRUE as default for
backward compatibility, but FALSE if you dont want population to be
expanded to 1:population. It could certainly be useful in some cases,
but you still need to know about the expansion to use it. I think most
of these bugs occur because users did not think about t...
2015 Jun 17
0
Add-on argument in sample()
...p; size == 1) {
> population
> } else if (!replace & length(population) >= size) {
> sample(population, size = size, replace = replace)
> } else {
> ...
> }
>
> Then the question would be if this test could be replaced with a new
> argument to sample, e.g. expandSingle, which has TRUE as default for
> backward compatibility, but FALSE if you dont want population to be
> expanded to 1:population. It could certainly be useful in some cases,
> but you still need to know about the expansion to use it. I think most
> of these bugs occur because users did n...
2015 Jun 15
3
Add-on argument in sample()
Hi.
I have a problem with the default behavior of sample(), which performs sample(1:x) when x is a single value.
This behavior is well explained in ?sample.
However, this behavior is annoying when the number of value is not predictable. Would it be possible to add an argument
that desactivates this and perform the sampling on a single value ? Examples:
> sample(10, size = 1, replace = FALSE)