How does one convert objects c("a","b","c") and
"d" into "abcd"?
> paste(c("a","b","c"), "d")
of course yields
[1] "a d" "b d" "c d"
--
Ajay Shah http://www.mayin.org/ajayshah
ajayshah at mayin.org
http://ajayshahblog.blogspot.com
<*(:-? - wizard who doesn't know the answer.
Hi,
See collapse argument in ?paste
R> paste( paste(c("a","b","c"), collapse =
""), "d", sep = "")
[1] "abcd"
Cheers,
Romain
Ajay Shah wrote:> How does one convert objects c("a","b","c")
and "d" into "abcd"?
>
> > paste(c("a","b","c"), "d")
> of course yields
> [1] "a d" "b d" "c d"
>
--
Mango Solutions
data analysis that delivers
Tel: +44(0) 1249 76 77 00
Fax: +44(0) 1249 76 77 07
Mob: +44(0) 7813 52 61 23
First 'c' and then 'paste' with 'collapse':
paste(collapse="", c(c("a", "b", "c"),
"d"))
See ?paste
G.
On Mon, Mar 17, 2008 at 04:26:17PM +0530, Ajay Shah
wrote:> How does one convert objects c("a","b","c")
and "d" into "abcd"?
>
> > paste(c("a","b","c"), "d")
> of course yields
> [1] "a d" "b d" "c d"
>
> --
> Ajay Shah
http://www.mayin.org/ajayshah
> ajayshah at mayin.org
http://ajayshahblog.blogspot.com
> <*(:-? - wizard who doesn't know the answer.
>
> ______________________________________________
> 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.
--
Csardi Gabor <csardi at rmki.kfki.hu> UNIL DGM
have a look at the collapse argument in ?paste.
paste(paste(c("a","b","c"), collapse =
""), "d", sep = ""))
HTH,
Thierry
------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry.Onkelinx op inbo.be
www.inbo.be
Do not put your faith in what statistics say until you have carefully
considered what they do not say. ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney
-----Oorspronkelijk bericht-----
Van: r-help-bounces op r-project.org [mailto:r-help-bounces op r-project.org]
Namens Ajay Shah
Verzonden: maandag 17 maart 2008 11:56
Aan: r-help
Onderwerp: [R] How does one do simple string concatenation?
How does one convert objects c("a","b","c") and
"d" into "abcd"?
> paste(c("a","b","c"), "d")
of course yields
[1] "a d" "b d" "c d"
--
Ajay Shah
http://www.mayin.org/ajayshah
ajayshah op mayin.org
http://ajayshahblog.blogspot.com
<*(:-? - wizard who doesn't know the answer.
______________________________________________
R-help op 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
2008-Mar-17 11:12 UTC
[R] How does one do simple string concatenation?
Try;
paste(c(c("a","b","c"), "d"),
collapse="")
On 17/03/2008, Ajay Shah <ajayshah at mayin.org>
wrote:> How does one convert objects c("a","b","c")
and "d" into "abcd"?
>
> > paste(c("a","b","c"), "d")
> of course yields
> [1] "a d" "b d" "c d"
>
> --
> Ajay Shah
http://www.mayin.org/ajayshah
> ajayshah at mayin.org
http://ajayshahblog.blogspot.com
> <*(:-? - wizard who doesn't know the answer.
>
> ______________________________________________
> 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.
>
--
Henrique Dallazuanna
Curitiba-Paran?-Brasil
25? 25' 40" S 49? 16' 22" O