Re: [Rd] Add-on argument in sample()

2015-06-18 Thread Radford Neal
William Dunlap writes: > I don't like the idea of having a length-1 dim attribute trigger some > behavior of sample. (Should a length-2 dim cause it to sample > rows of a matrix, as unique() and duplicated() do?). I wasn't too clear. I would want any dim attribute on its first argument to cause

Re: [Rd] Add-on argument in sample()

2015-06-18 Thread Jon Skoien
On 6/18/2015 12:25 AM, Hervé Pagès wrote: Hi, Special behavior of sample(x, ...) when length(x) is 1 is of course a bad feature. I think it pre-dates sample.int() which is what people should use these days if they want the behavior of sample(x, ...) when length(x) is 1. And because we now have

Re: [Rd] Add-on argument in sample()

2015-06-17 Thread Hervé Pagès
Hi, Special behavior of sample(x, ...) when length(x) is 1 is of course a bad feature. I think it pre-dates sample.int() which is what people should use these days if they want the behavior of sample(x, ...) when length(x) is 1. And because we now have sample.int(), this feature could in theory b

Re: [Rd] Add-on argument in sample()

2015-06-17 Thread William Dunlap
I don't like the idea of having a length-1 dim attribute trigger some behavior of sample. (Should a length-2 dim cause it to sample rows of a matrix, as unique() and duplicated() do?). S+'s sample() had another argument, 'n', that could be used to specify the size of the population to sample from

Re: [Rd] Add-on argument in sample()

2015-06-17 Thread Radford Neal
> 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 s

Re: [Rd] Add-on argument in sample()

2015-06-17 Thread Jon Skoien
On 6/16/2015 1:32 PM, Peter Meissner wrote: Am .06.2015, 14:55 Uhr, schrieb Millot Gael : 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 n

Re: [Rd] Add-on argument in sample()

2015-06-16 Thread Peter Meissner
Am .06.2015, 14:55 Uhr, schrieb Millot Gael : 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 i

Re: [Rd] Add-on argument in sample()

2015-06-15 Thread Henrik Bengtsson
You're not the first one, e.g. https://stat.ethz.ch/pipermail/r-devel/2010-March/057029.html https://stat.ethz.ch/pipermail/r-devel/2010-November/058981.html (I was bitten by this in a resampling scheme where the set sampled from was data driven). Here's a simple solution - taken from R.utils::r

[Rd] Add-on argument in sample()

2015-06-15 Thread Millot Gael
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 t