[R] [Q] Setting elements of a vector

Stefan Meyer stem at stem.de
Mon Nov 12 21:35:42 CET 2001


Hi!

I'm new to R and have problems with the following code:

<code>

awprob<-c(0.4,0.4,0.1,0.1)
awsample<-sample(c(1:4),3,awprob,replace=TRUE)

vec<-vector(mode="numeric",10000)
vec[]<-sum(sample(c(1:4),20,awprob,replace=TRUE))

</code>

My problem: The elements of vec have the same value. How
can I tell R that I want to have a *new* sample for each value
and not 10000 times the same sample?

A for-loop is not a good solution as it made R hang up ...

Thanx alot

Stefan

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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