Unfortunately the "shorter" version does not do what the op asked.
The correct way is using the 'collapse' parameter. Using paste on a
vector of length n with the parameter 'sep' you get a vector of n
elements. If you use "collapse" you get a single string.
Jose
Quoting Cristian Montes <cmon...@arauco.cl>:
Even shorter is
x<-c("a","b","c","d")
paste(x, sep="+")
Cheers,
Cristian Montes
-----Mensaje original-----
De: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] En nombre de Henrique
Dallazuanna
Enviado el: Martes, 03 de Agosto de 2010 04:37 p.m.
Para: phoebe kong
CC: r-help
Asunto: Re: [R] concatenate values in the vector
Try this:
paste(x, collapse = '+')
On Tue, Aug 3, 2010 at 5:34 PM, phoebe kong <sityeek...@gmail.com> wrote:
Hi all,
Is there a function that allow me to concatenate each value in a
vector to a string?
x<-c("a","b","c","d")
output string = a+b+c+d
Thanks,
phoebe
[[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.
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
[[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.
--
Dr. Jose I. de las Heras Email: j.delashe...@ed.ac.uk
The Wellcome Trust Centre for Cell Biology Phone: +44 (0)131 6507095
Institute for Cell & Molecular Biology Fax: +44 (0)131 6507360
Swann Building, Mayfield Road
University of Edinburgh
Edinburgh EH9 3JR
UK
*********************************************
Alternative email: nach.mcn...@gmail.com
*********************************************
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
______________________________________________
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.