Re: [R] converting a list with named member to a vector maintaining original names

2014-06-24 Thread arun
To get the vector setNames(stack(test)[,1],stack(test)[,2]) #ABCC2 ABCC5 ABCC5 #37280 12268 13308 #or setNames(unlist(test),stack(test)[,2]) #ABCC2 ABCC5 ABCC5 #37280 12268 13308 A.K. On , arun wrote: You could do: stack(test)[,2:1] #    ind values #1 ABCC2  37280 #2 ABCC5  12268 #3 AB

Re: [R] converting a list with named member to a vector maintaining original names

2014-06-24 Thread C Lin
You're amazing. Thanks so much! That's exactly what I am looking for. > From: istaz...@gmail.com > Date: Tue, 24 Jun 2014 14:32:27 -0400 > Subject: Re: [R] converting a list with named member to a vector maintaining > or

Re: [R] converting a list with named member to a vector maintaining original names

2014-06-24 Thread Ista Zahn
How about x <- unlist(test) (names(x) <- rep(names(test), times = sapply(test, length))) ? See also unlist2 from http://www.bioconductor.org/packages/release/bioc/html/AnnotationDbi.html Best, Ista On Tue, Jun 24, 2014 at 12:56 PM, C Lin wrote: > Dear R users, > > I have a list that I'd like

[R] converting a list with named member to a vector maintaining original names

2014-06-24 Thread C Lin
Dear R users, I have a list that I'd like to convert to a vector while preserving the original names. For example: test <- list(ABCC2=37280,ABCC5=c(12268,13308)); If I do unlist, it automatically renamed the ABCC5 to ABCC51 and ABCC52 > unlist(test)  ABCC2 ABCC51 ABCC52   37280  12268  13308