[R] vector creation

Berend Hasselman bhh at xs4all.nl
Sat Jul 31 15:10:35 CEST 2010



alekk wrote:
> 
> consider a simple function like
>       func = function(){ return(runif()) }
> and say that you would like to create a vector of size N, each entry being
> a call to this function "func". What is the equivalent of the python code
>       vect = [ func() for i in range(N)]
> Indeed, you cannot just call  vect<-rep( func(), N)  -  I guess that there
> also exists a one-liner to do that in R, doesn't it ?
> 

?runif

vect <- runif(N)

/Berend
-- 
View this message in context: http://r.789695.n4.nabble.com/vector-creation-tp2308840p2308844.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list