|
Hi R users,
I appreciate if you could give me some hint/help on this string operation. Suppose I have a list of string objects in varying sizes like [[1]] [1] "A" [2] "B" [3] "C" [[2]] [1] "D" [2] "E" [[3]] [1] "F" Then I would like to create a vector that contains all elements like [1] "A" "B" "C" "D" "E" "F" I tried do.call + rbind but no luck yet. Is there a function to do this operation or should I use append in the loop? Thanks in advance! Taka [[alternative HTML version deleted]] ______________________________________________ [hidden email] 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. |
|
Hello,
Does 'unlist' function do what you are asking about? Regards. Le 29/06/2012 11:52, Takatsugu Kobayashi a écrit : > Hi R users, > > I appreciate if you could give me some hint/help on this string operation. > > Suppose I have a list of string objects in varying sizes like > > [[1]] > [1] "A" [2] "B" [3] "C" > > [[2]] > [1] "D" [2] "E" > > [[3]] > [1] "F" > > Then I would like to create a vector that contains all elements like > > [1] "A" "B" "C" "D" "E" "F" > > I tried do.call + rbind but no luck yet. > > Is there a function to do this operation or should I use append in the loop? > > Thanks in advance! > > Taka > > [[alternative HTML version deleted]] > > ______________________________________________ > [hidden email] 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. > ______________________________________________ [hidden email] 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. |
|
Hi,
You could use "do.call" : a1<-c("A","B","C") a2<-c("D","E") a3<-"F" mylist<-list(a1,a2,a3) do.call("c",mylist) [1] "A" "B" "C" "D" "E" "F" A.K. ----- Original Message ----- From: Pascal Oettli <[hidden email]> To: Takatsugu Kobayashi <[hidden email]> Cc: [hidden email] Sent: Friday, June 29, 2012 3:16 AM Subject: Re: [R] Help for string opeation Hello, Does 'unlist' function do what you are asking about? Regards. Le 29/06/2012 11:52, Takatsugu Kobayashi a écrit : > Hi R users, > > I appreciate if you could give me some hint/help on this string operation. > > Suppose I have a list of string objects in varying sizes like > > [[1]] > [1] "A" [2] "B" [3] "C" > > [[2]] > [1] "D" [2] "E" > > [[3]] > [1] "F" > > Then I would like to create a vector that contains all elements like > > [1] "A" "B" "C" "D" "E" "F" > > I tried do.call + rbind but no luck yet. > > Is there a function to do this operation or should I use append in the loop? > > Thanks in advance! > > Taka > > [[alternative HTML version deleted]] > > ______________________________________________ > [hidden email] 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. > ______________________________________________ [hidden email] 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. ______________________________________________ [hidden email] 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. |
| Powered by Nabble | Edit this page |
