Partial matching with $ extractor.
I tried this again with R 2.15.3, the oldest version I have installed, and I still got the same behaviour. It extracts the first exact match, then the only partial match, then NULL.
On Tue, Jan 24, 2023 at 5:04 PM Rolf Turner <r.turner at auckland.ac.nz> wrote:
Has something changed, but I missed it?
My recollection is that $ extraction used partial matching.
E.g. if one did
junk <- list(yuck=1,yurk=2,y=3)
junk$y
then one would get 1 as the result; probably *not* the desired result.
See fortunes::fortune("toad").
To get the desired result, one would need to use junk[["y"]].
Likewise junk$yu would give 1; to get the value of "yurk", one would
need to use junk$yur or junk$yurk or (better?) junk[["yurk"]].
However, either my recollection is wrong, or something has changed.
When I do junk$y I get 3 (the "right" answer; the same as junk[["y"]]).
When I do junk$yu I get NULL (just as if I'd done junk[["yu"]]).
So: has something changed, or am I miss-remembering, or am I completely
confused about the whole issue?
Thanks for any enlightenment.
cheers,
Rolf Turner
--
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.