[Rd] sample (PR#2546)
Patrick Burns
pburns@pburns.seanet.com
Tue Feb 25 20:02:03 2003
There is rumour that some of my mail didn't go where it should have because
I don't know how to work email. It was suggested that I summarize here.
The issue is with sample when the first argument is length 1. Current
behaviour is:
> sample('a', 1)
Error in sample(x, size, replace, prob) : invalid first argument
> sample(3+0i, 1)
Error in x >= 1 : illegal comparison with complex values
> sample(TRUE, 1)
[1] 1
> sample(FALSE, 1)
[1] FALSE
> sample(NA, 1)
Error in if (length(x) == 1 && x >= 1) { :
missing value where logical needed
> sample(.5, 1)
[1] 0.5
The proposed behaviour is:
> sample('a', 1)
[1] "a"
> sample(3+0i, 1)
[1] 3+0i
> sample(TRUE, 1)
[1] TRUE
> sample(FALSE, 1)
[1] FALSE
> sample(NA, 1)
[1] NA
> sample(.5, 1)
[1] 0.5
For some reason that I haven't yet grasped, the current
behaviour seems to be preferred to the proposed behaviour.
Pat Burns
patrick@burns-stat.com