On Wed, Apr 30, 2014 at 3:33 PM, Scott Kostyshak <skost...@princeton.edu> wrote: > Hi Dennis, > > On Wed, Apr 30, 2014 at 3:03 PM, Fisher Dennis <fis...@plessthan.com> wrote: >> R 3.1.0 >> OS X >> >> Colleagues, >> >> I recently updated to 3.1.0 and I have encountered >> Warning messages: ... Name partially matched in data frame >> when I do something like: >> DATAFRAME$colname >> where colname is actually something longer than that (but unambiguous). >> >> I have much appreciated the partial matching capabilities because it fits >> with my workflow. I often receive updated data months after the initial >> code is written. In order to keep track of what I did in the past, I >> provide lengthy (unambiguous) names for columns, then abbreviate the names >> as I call them. This behavior has been termed “lazy” in various >> correspondence on this mailing list but it works for me and probably works >> for others. > > Why not store that information elsewhere? e.g. in an attribute? > >> I realize that the new message is only a warning but it is a minor nuisance. >> Would it be possible to add an >> option(partialMatch=TRUE) ## default is FALSE >> or something similar to suppress that behavior? That should keep both camps >> happy. > > There is currently no option to control that behavior and (although I > do understand your use case) I personally hope one is not implemented. > The reason is that you might put that option in your .Rprofile and > when you share your code with me I get errors that columns aren't > found.
Let me change this to "I would get warnings, which would make me worried." > You can of course redefine the `$`: > >> dataf <- data.frame(longColumn = 5) >> dataf$long > [1] 5 > Warning message: > In `$.data.frame`(dataf, long) : Name partially matched in data frame >> >> `$.data.frame` <- > + function (x, name) > + { > + a <- x[[name]] > + if (!is.null(a)) > + return(a) > + a <- x[[name, exact = FALSE]] > + return(a) > + } >> >> dataf$long > [1] 5 >> > > I hope you don't do that though. > > Another option is to use the more verbose dataf[["long", exact = FALSE]]. > > Scott > > > -- > Scott Kostyshak > Economics PhD Candidate > Princeton University Scott -- Scott Kostyshak Economics PhD Candidate Princeton University ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel