[R] Alternatives to unlist()

Jacques Wagnor jacques.wagnor at gmail.com
Fri May 4 17:53:04 CEST 2007


Given the following, one of the things I am trying to see is what % of
draws are below a certain number:

lambda <- 3
rate <- 5
n <- 5

set.seed(123)
v <- replicate(n, rexp(rpois(1,lambda), rate))
vv <- unlist(v)
cat("% of draws below 0.1:", round(length(subset(vv, vv <
0.1))/length(vv)*100,0), "%\n")

In actuality, my lambda, rate, and n are 26, 10, 1000000,
respectively; which in effect makes the length of vv roughly equal
26'000'000. When I run cat(...), I get the following:

Error: cannot allocate vector of size 101540 Kb
In addition: Warning messages:
1: Reached total allocation of 1015Mb: see help(memory.size)
2: Reached total allocation of 1015Mb: see help(memory.size)

Rather than keep the code as is and resort to memory.limit(), I would
like to see how the code can be modified (i.e., alternatives to
unlist()) such that I could still see what % of draws are below a
certain number.

I'd appreciate any suggestions.

Regards,

platform i386-pc-mingw32
arch     i386
os       mingw32
system   i386, mingw32
status
major    2
minor    2.1
year     2005
month    12
day      20
svn rev  36812
language R



More information about the R-help mailing list