On 20-Oct-08 21:19:21, Stefan Evert wrote:
> On 20 Oct 2008, at 22:57, (Ted Harding) wrote:
>> I'm wondering if there's a compact way to achieve the
>> following. The "dream" is that one could write
>>
>>  rep(c(0,1),times=c(3,4,5,6))
>>
>> which would produce
>>
>> # [1] 0 0 0 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1
>>
>> in effect "recycling" x through 'times'.
> 
> rep2 <- function (x, times) rep(rep(x, length.out=length(times)),
> times)
> 
> rep2(c(0,1),times=c(3,4,5,6))
>   [1] 0 0 0 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1
> 
> Any prizes for shortest solution? ;-)
> 
> Best,
> Stefan

If ever we are both within reach of 'en øl', then yes.
But Gabor came up with a shorter one.

I tried to shorten Gabor's but failed.

However, all competitors are entitled to a consolation prize!
(And that includes me ... )
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 20-Oct-08                                       Time: 22:59:16
------------------------------ XFMail ------------------------------

______________________________________________
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