hello,
i am familiar with the paste command with which i can paste for exaple:
object <- "Hello"
paste(object,"World")
now i would like to be able to paste all the elements of the same vector
together e.g:
object <- c("Hello","World")
getting as a result also:
"Hello World".
Does anyone know the solution to this problem?
Thank you very much in advance.
Marion
[[alternative HTML version deleted]]
R. Michael Weylandt
2011-Sep-19 14:00 UTC
[R] pasting elements of one character vector together
paste(...,collapse=" ") Michael Weylandt On Mon, Sep 19, 2011 at 9:58 AM, Marion Wenty <marion.wenty@gmail.com>wrote:> hello, > > i am familiar with the paste command with which i can paste for exaple: > > object <- "Hello" > paste(object,"World") > > now i would like to be able to paste all the elements of the same vector > together e.g: > > object <- c("Hello","World") > > getting as a result also: > > "Hello World". > > Does anyone know the solution to this problem? > > Thank you very much in advance. > > Marion > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. >[[alternative HTML version deleted]]
Dimitris Rizopoulos
2011-Sep-19 14:04 UTC
[R] pasting elements of one character vector together
Try this:
object <- c("Hello", "World")
paste(object, collapse = " ")
I hope it helps.
Best,
Dimitris
On 9/19/2011 3:58 PM, Marion Wenty wrote:> hello,
>
> i am familiar with the paste command with which i can paste for exaple:
>
> object<- "Hello"
> paste(object,"World")
>
> now i would like to be able to paste all the elements of the same vector
> together e.g:
>
> object<- c("Hello","World")
>
> getting as a result also:
>
> "Hello World".
>
> Does anyone know the solution to this problem?
>
> Thank you very much in advance.
>
> Marion
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/