From btyner at gmail.com  Fri Aug 10 22:47:19 2007
From: btyner at gmail.com (Benjamin Tyner)
Date: Fri, 10 Aug 2007 16:47:19 -0400
Subject: [Rd] suggestion with ambiguous object component replacement
Message-ID: <5f88b2c50708101347p3ae6d7ebt67d43ffaf41e4b8@mail.gmail.com>

?"[<-" says

"When replacing (that is using indexing on the lhs of an assignment)
NA does not select any element to be replaced. As there is ambiguity
as to whether an element of the rhs should be used or not, this is
only allowed if the rhs value is of length one (so the two
interpretations would have the same outcome)."

This is quite reasonable to me; for example,

letters[NA] <- "z"

does not throw an error but

letters[NA] <- c("z","z")

does. However I wonder why assignments like

letters[c(2,2)] <- c("b1","b2")

are allowed, since at least to me it is not clear at all that "b2" is
the intended replacement. I would think that at the very least this
should throw a warning. I apologize if this has already been
discussed.

Thanks
Ben



[Rd] suggestion with ambiguous object component replacement
Benjamin Tyner