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

From: Søren Højsgaard <Soren.Hojsgaard_at_agrsci.dk>
Date: Thu, 6 Dec 2007 13:04:56 +0100


Dear all,
Starting from a recent version of R, the $ became "unusable" on atomic vectors, e.g.
> x <- c(a=1,b=2)
> x$a

NULL
Warning message:
In x$a : $ operator is invalid for atomic vectors, returning NULL  

I can of course do
> x['a']

- but that requires more typing (5 characters rather than 2).  

Apologies if I've missed a an announcement regarding this, but 1) Is there an alternative to the ['a'] and 2) Why was this change made?  

Regards
Søren  



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 06 Dec 2007 - 12:06:49 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 06 Dec 2007 - 15:30:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.