combine elements of a character vector into a character

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

combine elements of a character vector into a character

Taka Matzmoto
Hi R users

I have a simple question to ask

x <- c("a","b","c")
x
[1] "a" "b" "c"

I like to have "abc" instead of having "a" "b" "c"

I tried to use paste and other functions related to character.

Is there any function (command) that enable me to combine elements of a
character vector into one character ?

Thanks

______________________________________________
[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
Reply | Threaded
Open this post in threaded view
|

Re: combine elements of a character vector into a character

Dimitris Rizopoulos
probably you missed the 'collapse' argument of paste(); try this:

paste(x, collapse = "")


Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://www.med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message -----
From: "Taka Matzmoto" <[hidden email]>
To: <[hidden email]>
Sent: Tuesday, February 14, 2006 9:32 AM
Subject: [R] combine elements of a character vector into a character


> Hi R users
>
> I have a simple question to ask
>
> x <- c("a","b","c")
> x
> [1] "a" "b" "c"
>
> I like to have "abc" instead of having "a" "b" "c"
>
> I tried to use paste and other functions related to character.
>
> Is there any function (command) that enable me to combine elements
> of a
> character vector into one character ?
>
> Thanks
>
> ______________________________________________
> [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
>


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

______________________________________________
[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
Reply | Threaded
Open this post in threaded view
|

Re: combine elements of a character vector into a character

Diethelm Wuertz
In reply to this post by Taka Matzmoto
Taka Matzmoto wrote:

>Hi R users
>
>I have a simple question to ask
>
>x <- c("a","b","c")
>x
>[1] "a" "b" "c"
>  
>
Try

paste(x, collapse = "")


DW

>I like to have "abc" instead of having "a" "b" "c"
>
>I tried to use paste and other functions related to character.
>
>Is there any function (command) that enable me to combine elements of a
>character vector into one character ?
>
>Thanks
>
>______________________________________________
>[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
>
>  
>

______________________________________________
[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