[Rcpp-devel] Struggling with Rcpp sugar

Hadley Wickham h.wickham at gmail.com
Sun Nov 18 17:08:33 CET 2012


>> recycle(x, y, z);
>>
>> Hadley
>
>
> In a way, we can already use sugar rep_len.
>
> rep_len( x, 30 )
>
> will recycle x into a vector of length 30, lazily.

Agreed, but a helper function would automate this process:

int length = max(x.length(), y.length(), z.length())
# check integer multiples
x = rep_len(x, length)
y = rep_len(y, length)
z = rep_len(z, length)

etc.

Hadley


-- 
RStudio / Rice University
http://had.co.nz/


More information about the Rcpp-devel mailing list