Skip to content
Prev 171293 / 398506 Next

how to recover a list structure

Here is one way that might work.

x <- list(a=runif(10), b=runif(30), c=runif(25))
# unlist and then construct a factor to put them back together
x.u <- unlist(x)
x.f <- unlist(mapply(rep, names(x), sapply(x, length)))
# find the lowest 5 values and set to -1
x.u[order(x.u)[1:5]] <- -1
# put back together
split(x.u, x.f)
On Sat, Feb 21, 2009 at 11:51 PM, <mauede at alice.it> wrote: