Re: [R] how to recover a list structure

2009-02-22 Thread Dimitris Rizopoulos
another option is to use relist(), e.g., x <- list(a=runif(10), b=runif(30), c=runif(25)) x <- as.relistable(x) ux <- unlist(x) ux[order(ux)[1:5]] <- -1 relist(ux) Best, Dimitris jim holtman wrote: Here is one way that might work. x <- list(a=runif(10), b=runif(30), c=runif(25)) # unlist a

Re: [R] how to recover a list structure

2009-02-21 Thread jim holtman
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 t

[R] how to recover a list structure

2009-02-21 Thread mauede
I am experiencing some problems at working with lists at high level. In the following "coef" contains the original DWT coefficients organized in a list. Thorugh applying the following two commands: coef.abs <- lapply(unlist(coef,recursive=FALSE,use.names =TRUE),abs) coef.abs.sorted <- sort(u