[R] combing list objects

Rui Barradas ruipbarradas at sapo.pt
Mon Sep 3 21:59:47 CEST 2012


Hello,

Try ?unlist.
unlist(abun)

Hope this helps,

Rui Barradas
Em 03-09-2012 17:06, chris20 escreveu:
> Hi,
> I am trying to combine a long list but I can't work out how to do it, for
> example:
>
> abun<-list(rep(0,5),rep(0,7),rep(0,4),rep(0,10))
> nb<-c(5,5,1,8)
>
> fill.abun <- function(x, y) {
>          set <- sample(1:length(x), size = y)
>          x[set] <- rlnorm(length(set))
>          return(x)
>      }
>              
> abun <- mapply(fill.abun, abun, nb)
> abun
>
> ## I want all the data in one list or column which I can extract to a
> dataframe or matrix
> ## the best I have come up with is:
>
> abun2<-c(abun[[1]],abun[[2]],abun[[3]],abun[[4]])
>
> ## but I will have a lot more data and so this is not feasible
>
> Thanks,
> Chris
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/combing-list-objects-tp4642071.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list