From kjetilbrinchmannhalvorsen at gmail.com  Tue Jun 22 03:15:47 2010
From: kjetilbrinchmannhalvorsen at gmail.com (Kjetil Halvorsen)
Date: Mon, 21 Jun 2010 21:15:47 -0400
Subject: [Rd] proposed change to 'sample'
In-Reply-To: <4C1EFF4D.4090206@gmail.com>
References: <4C1DE879.6040303@pburns.seanet.com>
	<77EB52C6DD32BA4D87471DCD70C8D700031C9A21@NA-PA-VBE03.na.tibco.com>
	<4C1E8408.1010609@gmail.com>
	<AANLkTilJm651mXnqOUFWhipqV11QOldSyjCyUD6IHric@mail.gmail.com>
	<4C1EFF4D.4090206@gmail.com>
Message-ID: <AANLkTinxWeL7gA5VshALNRIOl-SCbKX_43FXbaA72I-k@mail.gmail.com>

On Mon, Jun 21, 2010 at 1:57 AM, Peter Dalgaard <pdalgd at gmail.com> wrote:
> Hadley Wickham wrote:
>>> I would be more inclined to make sampling from a vector the normal case,
>>> and default x to say 1:max(n, size), forcing users to say sample(n=5) if
>>> sampling from x=1:5 is desired. This could be a manageable change; the
>>> deprecation sequence is a bit painful to think through, though.
>>
>> Don't we already have sample.int for that case?
>>
>> Hadley
>>
>
> For the 2nd case, yes, but I was aiming at getting sample(x) ==
> x[sample.int(length(x))] also in the length 1 case, removing the
> ambiguity. This would obviously break some code, but I'd expect not all
> that much. However, it cannot be changed in one go, we'd need to go
> through a sequence where we (e.g.)
>
> 1. warn about length(x)==1
> 2. say that length(x)==1 is deprecated
> 3. have length(x)==1 throw an error
> 4. wait....
> 5. give length(x)==1 a new meaning
>

Please implement this sequence!

Kjetil

> --
> Peter Dalgaard
> Center for Statistics, Copenhagen Business School
> Phone: (+45)38153501
> Email: pd.mes at cbs.dk ?Priv: PDalgd at gmail.com
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] proposed change to 'sample'
Kjetil Halvorsen