Hi, On Tue, Jul 17, 2012 at 10:40 AM, Paulo Barata <paulo.bar...@ensp.fiocruz.br> wrote: > > Dear Frans and Peter, > > Yes, the notation df[,'var'] is able to catch a non-existent > variable var inside a data frame df. But the notation df$var > isn't. > > So we have this situation, where two different notations, which > (as far as I understand) perform the same action, have different > kinds of response.
But they don't perform the same action: the defaults are different. This is documented, although verbosely and somewhat confusingly, see for instance ?"$" and pay particular attention to the sections on partial matching. > Couldn't this situation be fixed? Isn't it possible to make the > df$var notation to issue an error when referring to a non-existent > variable inside the data frame? Not without completely changing the way partial matching is handled. The answer has already been offered: don't use $ - it's really just there as a shortcut, and like all shortcuts has attendant risks not found on the longer, smoother main road. Sarah > Thank you very much. > > Paulo Barata > -- Sarah Goslee http://www.functionaldiversity.org ______________________________________________ R-help@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.