Hi,

I have discovered that sample() fails with an uninformative error
message when the x argument is a single NA of type double or integer.

I can reproduce the problem with the following code:

base::sample(NA)
# NA is of logical type above
base::sample(NA_character_)
base::sample(NA_complex_)
base::sample(NA_real_)
base::sample(NA_integer_)


The last two lines throw the following error:
Error in if (length(x) == 1L && is.numeric(x) && x >= 1) { :
  missing value where TRUE/FALSE needed

My sessionInfo() :

R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.5 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base


Best,

Travis McArthur

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to