[R] Error: cannot take a sample larger than the population

Aldi Kraja aldi at wustl.edu
Sat Dec 30 10:04:55 CET 2006


Hi,
In Splus7 this statement
xlrmN1 <- sample(c(0,1,2),400 ,prob=c(0.02 ,0.93 ,0.05 ))
worked fine, but in R the interpreter reports that the length of the 
vector to chose c(0,1,2) is shorter than the size of many times I want 
to be selected from the vector c(0,1,2).
Any good reason?
See below the error.

 > xlrmN1 <- sample(c(0,1,2),400 ,prob=c(0.02 ,0.93 ,0.05 ))
Error in sample(length(x), size, replace, prob) :
        cannot take a sample larger than the population
 when 'replace = FALSE'
Execution halted

TIA,

Aldi

--



More information about the R-help mailing list