Skip to content
Back to formatted view

Raw Message

Message-ID: <419EED2318C2164DB95FBB20AA8810D8083953@smtp_mail.bankofamerica.com>
Date: 2013-03-21T17:00:38Z
From: Yuan, Rebecca
Subject: easy way of paste
In-Reply-To: <1363879246.27778.YahooMailNeo@web142606.mail.bf1.yahoo.com>

Hello A.K.,

Thanks! I use collapse instead of sep and get the answer.

Cheers,

Rebecca

-----Original Message-----
From: arun [mailto:smartpink111 at yahoo.com] 
Sent: Thursday, March 21, 2013 11:21 AM
To: Yuan, Rebecca
Cc: R help
Subject: Re: [R] easy way of paste

?dat2<-as.data.frame(matrix(1:20,ncol=5))
?colnames(dat2)<- c("aa","dummy1","dummy2","bb","cc")
?paste(colnames(dat2),collapse="+")
#[1] "aa+dummy1+dummy2+bb+cc"
A.K.



----- Original Message -----
From: "Yuan, Rebecca" <rebecca.yuan at bankofamerica.com>
To: R help <r-help at r-project.org>
Cc: 
Sent: Thursday, March 21, 2013 11:15 AM
Subject: [R] easy way of paste

Hello,

Is there a better way to use paste such as:

a = paste(colnames(list.indep)[1],colnames(list.indep)[2],colnames(list.indep)[3],colnames(list.indep)[4],colnames(list.indep)[5],sep="+")



> a

[1] "aa+dummy1+dummy2+bb+cc"



I tried



a = paste(colnames(list.indep)[1:5],sep="+")



> a

[1] "aa" "dummy1"? ? ? ? ? ?  "dummy2"? ? ? ? ? ? ? "bb"? ? ? ? ? ? ? ? ?  "cc"

But it will not give me the way I want.

Thanks,

Rebecca


----------------------------------------------------------------------
This message, and any attachments, is for the intended r...{{dropped:15}}