[R] alternative way to replicate()

jim holtman jholtman at gmail.com
Sun Dec 7 16:32:49 CET 2008


Is this what you want:

> paste(rep('2',5), collapse=',')
[1] "2,2,2,2,2"
>


On Wed, Dec 3, 2008 at 5:36 AM, Johannes Hüsing <johannes at huesing.name> wrote:
> Am 03.12.2008 um 09:06 schrieb Liviu Andronic:
>
>> Dear all,
>>
>> I'm looking for an alternative way to replicate the "2," string for an
>> x number of times, and end up with one string containing "2," x times.
>> I can partly achieve this using replicate().
>>>
>>> y <- rep("2,", times=3)
>>> y
>>>
>
> JFTR: replicate() is a different function from rep(). See ?rep and
> ?replicate.
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list