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 <[EMAIL PROTECTED]> 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
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
Thanks all. All solutions are usable. These two I received off-list:
> toString(paste(rep("2",3), sep=","))
[1] "2, 2, 2"
and
> paste(rep("2,",3),collapse="")
Liviu
On Wed, Dec 3, 2008 at 9:14 AM, Dimitris Rizopoulos
<[EMAIL PROTECTED]> wrote:
> have a look at ?paste(), e.g.,
>
> paste(rep(2, 3
have a look at ?paste(), e.g.,
paste(rep(2, 3), collapse = ",")
and if you need a comma at the end, then you can again use paste(),
paste(paste(rep(2, 3), collapse = ","), ",", sep = "")
I hope it helps.
Best,
Dimitris
Liviu Andronic wrote:
Dear all,
I'm looking for an alternative way to
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
[1] "2," "2," "2,"
The output that I am looking for is, however, "2,2,
5 matches
Mail list logo