[R] how to convert list into a vector

Henrique Dallazuanna wwwhsd at gmail.com
Thu Oct 8 18:34:09 CEST 2009


If you want do.call, you can use c indeed of cbind:

do.call(c, list(1:5, 6:8, 9:11))

On Thu, Oct 8, 2009 at 12:13 PM, delnatan <delnatan at gmail.com> wrote:
>
> Hi ,
>
> I want to convert a my list:
>
>> myList
> [[1]]
> [1] 1 2 3 4 5
> [[2]]
> [1] 6 7 8
> [[3]]
> [1] 9 10 11
>
> into something like c(1,2,3,4,5,6,7,8,9,10,11)
>
> I realized that this is possible by
>
>> c(do.call("cbind",myList))
>
> But only when list[[1]] through list[[3] have equal length of vectors within
> them
>
> Any ideas?
>
> Thank you for time,
> -Daniel
> --
> View this message in context: http://www.nabble.com/how-to-convert-list-into-a-vector-tp25803241p25803241.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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O




More information about the R-help mailing list