Skip to content

replicating lists

6 messages · David James, Jonathan Rougier, Brian Ripley +1 more

#
hi,

Yes, I agree that the work-around needs some care, but I'm not sure 
we need to wrap the list itself -- we're simply using properties of 
"[" on lists.  If the subscript is rep(1, 10), then we'll get the 
first element 10 times (which is *not* replicating the list).
To get the replication we need to index every element in 
the list as many times as required.

David
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Wed, 11 Apr 2001, David James wrote:

            
Not sure I follow you here.  I want n copies of an arbitrary list, as a
list, so list(fred)[rep(1, n)] is desired, where fred is the list I want
replicated.  Unfortuntely this does not solve the underlying problem,
which is that I want to do
which breaks because "rep", invoked by "array", currently fails to handle
complex lists.  However I am happy to report that
does work as expected:
So that's the work-around in my particular case.

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
The most obvious fix is internal, and that should be done fairly soon.
On Wed, 11 Apr 2001, David James wrote:

            

  
    
#
Hi Brian,

After a discussion with David James can you clarify exactly what you think
the behaviour of "rep" will be?  The three alternatives for rep(fred, 5)
would appear to be
I was expecting the first, as this makes sense in the context of
but I can see that the second is also a natural way to think about
replicating a list.  I also notice that S+ uses version 3.  Personally I
don't like version 3 as it is going to duplicate names, and it is not
going to fit with "array".

Confused, Jonathan.
On Wed, 11 Apr 2001, Prof Brian Ripley wrote:

            
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Thu, 12 Apr 2001, Jonathan Rougier wrote:

            
We follow the prototype in cases of doubt, so version 3.  *However*,
S-PLUS does different things by version, so version 6.0 drops the
duplicated names.  I really think only 3 makes sense: a list is a generic
vector, and you do exactly the same thing as for any other sort of vector.
The only issue is the names, and

x <- letters[1:3]
names(x) <- x
rep(x, 5)

drops names in S+6.0, keeps them in S+3.4 and R.  So the S-PLUS versions
are doing consistent things with character vectors and lists.

As for array, again it fits with all other sorts of vectors.   I think you
are misconceiving what a list is: think of it as a vector with
components of different types.  An array list is just an array with
elements of different types.  The problems you had with [[1, ]] stem from
the same problem,
#
We had a similar discussion when fixing all.equal problems with lists.
These are generic vectors and not hashtables, hence I think the above is
the ``right approach'' (following the general principle).

-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._