I am trying to combine the value of a variable and text. e.g. I want ?test1?, with no spaces. I try: h=1 paste(?test?,1) But get: [1] "test 1" (i.e. there is a space between ?test?? and ?1?) Is there a way to eliminate the space?
I found the answer:
add sep="" to the paste command
paste('test',1,sep="")
--- r user <ruser2006 at yahoo.com> wrote:
> I am trying to combine the value of a variable and
> text.
>
> e.g.
> I want ?test1?, with no spaces.
>
> I try:
>
> h=1
> paste(?test?,1)
>
> But get:
> [1] "test 1"
>
> (i.e. there is a space between ?test?? and ?1?)
>
> Is there a way to eliminate the space?
>
>
> __________________________________________________
> Do You Yahoo!?
> protection around
> http://mail.yahoo.com
>
I don't think the help page for paste is all that hard to read or understand, is it? Please read about the `sep' option (and note its default). Andy From: r user> > I am trying to combine the value of a variable and > text. > > e.g. > I want "test1", with no spaces. > > I try: > > h=1 > paste('test',1) > > But get: > [1] "test 1" > > (i.e. there is a space between "test'" and "1") > > Is there a way to eliminate the space? > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > >
Try
paste('test',1,sep='')
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of r user
Sent: Wednesday, January 25, 2006 1:58 PM
To: rhelp
Subject: [R] paste - eliminate spaces?
I am trying to combine the value of a variable and text.
e.g.
I want "test1", with no spaces.
I try:
h=1
paste('test',1)
But get:
[1] "test 1"
(i.e. there is a space between "test'" and "1")
Is there a way to eliminate the space?
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
Just read more carefully the online help for paste (?paste).
You have:
sep: a character string to separate the terms.
and the default value for sep is " " (a space).
So, just use:
> paste("test", 1, sep = "")
Best,
Philippe Grosjean
r user wrote:> I am trying to combine the value of a variable and
> text.
>
> e.g.
> I want ?test1?, with no spaces.
>
> I try:
>
> h=1
> paste(?test?,1)
>
> But get:
> [1] "test 1"
>
> (i.e. there is a space between ?test?? and ?1?)
>
> Is there a way to eliminate the space?
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
>
>