[Rd] replicating lists

Jonathan Rougier J.C.Rougier@durham.ac.uk
Wed, 11 Apr 2001 09:15:26 +0100 (BST)


Hi Everyone,

At the moment it is not possible to replicate complex lists, but only
simple ones:

> rep(list(fred = 1:10), 10) # works fine
> rep(list(fred = 1:10, happy = "squash"), 10)
Error in rep(list(fred = 1:10, happy = "squash"), 10) : 
        Unimplemented feature in rep

There is nothing in ?rep that suggests that the latter should not work,
and I think it would be a desirable feature if it did.  For example, I
want to create an array of lists, and it would be nice for me to set
default values in the array function, rather than having to loop through
the components and setting them individually.

I've had a quick look in do_rep in seq.c and to my untrained eye it looks
as though the LISTSXP case of the main switch might need to be replaced by
a VECSXP, but I am not sure about other implications.

Cheers, Jonathan.

Jonathan Rougier                       Science Laboratories
Department of Mathematical Sciences    South Road
University of Durham                   Durham DH1 3LE
tel: +44 (0)191 374 2361, fax: +44 (0)191 374 7388
http://www.maths.dur.ac.uk/stats/people/jcr/jcr.html

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._