On Fri, Oct 29, 2010 at 4:49 AM, Ron Michael <ron_michae...@yahoo.com> wrote:
> Hi all, I want to club different objects (character type) to a single one and 
> using paste() function that can be done happily. However the problem with 
> paste function is the separator field is unique for all underlying objects. 
> If I put separator as "-" then this will come in between all underlying 
> objects which are to be clubbed.
>
> Therefore I am wondering whether there is any mechanism to put different 
> separators for different places. Trivially this can be done by applying 
> paste() function repeatedly. However I feel there must be some single 
> mechanism for doing that.
>
> Here is one example, where I apply paste() function twice to incorporate 2 
> different separators:
>> paste(paste("a", "b", sep=","), "c", sep=":")
> [1] "a,b:c"
>
> Can the same thing be done using paste() function once? something like:
> paste("a", "b", "c", sep=c(",", ":")) # this put 1st separator everywhere 
> which is not intended
>

Try sprintf instead:

   sprintf("%s,%s:%s", "a", "b", "c")


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
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.

Reply via email to