Skip to content
Prev 131410 / 398502 Next

$ operator is invalid for atomic vectors, returning NULL - what is the right thing to do then?

On Thu, 6 Dec 2007, S?ren H?jsgaard wrote:

            
It has always returned NULL on atomic vectors: see the help page.
E.g. in R 2.0.0 from 2004:
NULL
a
1

The warning was added three versions of R ago: the announcement is in the 
NEWS file for 2.5.0.

USER-VISIBLE CHANGES

     o   Using $ on an atomic vector now raises a warning, as does use
         on an S4 class for which a method has not been defined.

I think you have exemplified the answer to your question '2)': because 
users misunderstood what it did.

In R 2.7.0 this will be an error, since package programmers did not seem 
to be heeding the warnings.