Re: [R] How apply a function to a list while maintaining list name?

2009-10-24 Thread Jorge Ivan Velez
Hi Peng, Try lapply(L, paste, collapse="") $x [1] "ab" $y [1] "ab" HTH, Jorge On Sat, Oct 24, 2009 at 12:02 PM, Peng Yu <> wrote: > I use lapply to apply a function to the list 'L'. But of course, the > list names in 'X' is not maintained. I'm wondering if there is a > function that can mai

[R] How apply a function to a list while maintaining list name?

2009-10-24 Thread Peng Yu
I use lapply to apply a function to the list 'L'. But of course, the list names in 'X' is not maintained. I'm wondering if there is a function that can maintain the list names as well as apply the function. $ Rscript lapply.R > L=list(x=c('a','b'), y=c('a','b')) > L $x [1] "a" "b" $y [1] "a" "b"