[R] ? about sample
jimi adams
imij at columbus.rr.com
Fri Mar 8 13:05:57 CET 2002
i am trying to use the
sample command and have one question about it:
i am getting the error
Error in sample(length(x), size, replace, prob) :
insufficient positive probabilities
when i use something like:
sample (1:4, prob=c(0,0,1,0))[1]
i was expecting that to return a 3 every time
while this is not exactly what i am using it for, i need the capabilities to
deal with zeros (as the probability valuees that i will be using wil vary,
and sometimes will include zeros), and this seems like the zero's are the
problem...
currently i am assigning zero values in my initial probability vector to a
miniscule value(1E-4)
is there a more efficient way to deal with this, or another command that
does a similar thing to only select a single element, where as sample orders
the entire set according to the prob?
if it helps, i am using R 1.4.0 on win-me
thanks
jimi adams
Department of Sociology
The Ohio State University
300 Bricker Hall
190 N Oval Mall
Columbus, OH 43210-1353
614-688-4261
our mind has a remarkable ability to think of contents as being independent
of the act of thinking
-georg simmel
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list