Re: [R] sample function and memory usage

2007-05-09 Thread Prof Brian Ripley
On Tue, 8 May 2007, Victor Gravenholt wrote: As a part of a simulation, I need to sample from a large vector repeatedly. For some reason sample() builds up the memory usage ( 500 MB for this example) when used inside a for loop as illustrated here: X - 1:10 P - runif(10) for(i in

[R] sample function and memory usage

2007-05-08 Thread Victor Gravenholt
As a part of a simulation, I need to sample from a large vector repeatedly. For some reason sample() builds up the memory usage ( 500 MB for this example) when used inside a for loop as illustrated here: X - 1:10 P - runif(10) for(i in 1:500) Xsamp - sample(X,3,replace=TRUE,prob=P)