From Kurt.Hornik@ci.tuwien.ac.at  Wed Jun 24 07:21:36 1998
From: Kurt.Hornik@ci.tuwien.ac.at (Kurt Hornik)
Date: Wed, 24 Jun 1998 08:21:36 +0200 (CEST)
Subject: redundant names
In-Reply-To: <98Jun23.110915edt.13445@mailgate.bank-banque-canada.ca>
References: <98Jun23.110915edt.13445@mailgate.bank-banque-canada.ca>
Message-ID: <13712.39664.226966.564351@pc87.maho.magnaeu.com>

>>>>> Paul Gilbert writes:

> I don't often suggest an incompatibility with S, but I think this behavior in S
> and R is very dangerous:

>> c(list(a="a"), b=2, a=1)$a
> [1] "a"
>> c(list(a="a"), b=2, a=1)
> $a
> [1] "a"
> $b
> [1] 2
> $a
> [1] 1

> I think this is a case where we may want incompatibility with S in
> order to enforce good programming and catch unintentional errors. I
> cannot think of a case where I would want a list with two elements
> having the same name. I would suggest eliminating all but the first of
> any redundant names (and issuing a warning?).

I am not saying that I have a good example (see below), but some may
want it this way.  Suppose you have a list of complicated records and
you (for some admittedly strange reason) decide you want to store labels
directly as the list names.

E.g.,
	x <- list(a = 3, b = 2, a = 4)
which you later use with
	x[names(x) == "a"]
to work on the records you want.

So I think we should not rule this out in c() (or e.g. [rc]bind()).

But we need to spend more time on how we want list assignment to be in
any case.

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


redundant names
Kurt Hornik