Quantcast

Help for string opeation

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Help for string opeation

Takatsugu Kobayashi-2
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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Help for string opeation

Pascal Oettli-2
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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Help for string opeation

arun kirshna
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.
Loading...