Skip to content

Puzzling... puzzling... puzzling...

4 messages · Duncan Murdoch, William Dunlap, Michael

#
On 13/02/2012 2:00 PM, Michael wrote:
How did you determine that?  The test below just shows that they contain 
the same thing.
Changing one of them and seeing the other one change would show that 
they point to the same memory area.  This can happen with environments:  
if you create env1 and set env2 <- env1, then changes to either 
environment will affect the other, because that's how environments 
work.   That's not true of most of the other kinds of objects in R.  
(The exceptions are fairly exotic things that you are unlikely to use.)

Duncan Murdoch
#
Replace the syntax List$Name with List[["Name"]]
and see if things work better.

'[[' does not do the partial matching that '$' does.
E.g.,
   x <- list(AB=10, BC=20, CD=30)
   x$A # returns 10 because "A" is the initial part of exactly one name in x, "AB"
   x[["A"]] # returns NULL

However, if you have
   y <- list(AB=1, AC=2, AD=3)
then y$A will return NULL because there is not a unique partial
match to "A" among the names of y.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
1 day later