[R] preventing repeat in "paste"

Dimitri Liakhovitski dimitri.liakhovitski at gmail.com
Fri Feb 25 23:46:58 CET 2011


Thanks a lot, everyone!
collapse it is!
Dimitri

On Fri, Feb 25, 2011 at 5:42 PM,  <Seeliger.Curt at epamail.epa.gov> wrote:
>> s<-"start"; e<-"end"
>> middle<-as.character(c(1,2,3))
>>
>> I would like to get the following result:
>> "start 123 end" or "start 1 2 3 end" or "start 1,2,3 end"
>>
>> How can I avoide this (undesired) result:
>> paste(s,middle,e,sep=" ")
>
> Sometimes you just have to do something more than once:
> paste(s, paste(middle, collapse=','), e, sep=" ")
>
> cur
> --
> Curt Seeliger, Data Ranger
> Raytheon Information Services - Contractor to ORD
> seeliger.curt at epa.gov
> 541/754-4638
>
>
>        [[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.
>



-- 
Dimitri Liakhovitski
Ninah Consulting
www.ninah.com



More information about the R-help mailing list