Terry Therneau
2013-Jul-01 20:51 UTC
[Rd] Problem with anova and the new abbreviation restrictions
An unwanted side effect of the new restrictions on abrreviated names. The anova.coxph command, in a slavish copy of anova.lm etc, returns a data frame with column labels of loglik Chisq Df Pr(>|Chi|) If one tries to extract the final column of the table errors result since it is not a standard R variable name. > afit <- anova(lm(conc ~ uptake, CO2)) > afit$P [1] 2.905607e-06 NA Warning message: In `$.data.frame`(afit, P) : Name partially matched in data frame > afit$Pr(>F) Error: unexpected '>' in "afit$Pr(>" The second is a result of allowing TAB completion of the name. Yes, experienced folks can sneak around it, but should this be upgraded to match and "ease of use" criteria? Add an [.anova subscript method that allows for shortened names? I'm still in favor of an option() that controls this new behavior with values of "allow", "warn", and "error" so that I can at least turn it off for me. (I work on many data sets created by SAS programmers that are in love with excessively long names, and use batch scripts so name completion isn't avail during script creation). But this is more local to me, and does not address the primary question above in a general way. Terry T
Hadley Wickham
2013-Jul-01 21:01 UTC
[Rd] Problem with anova and the new abbreviation restrictions
On Mon, Jul 1, 2013 at 3:51 PM, Terry Therneau <therneau at mayo.edu> wrote:> An unwanted side effect of the new restrictions on abrreviated names. > > The anova.coxph command, in a slavish copy of anova.lm etc, returns a data > frame with column labels of > loglik Chisq Df Pr(>|Chi|) > > If one tries to extract the final column of the table errors result since it > is not a standard R variable name. > >> afit <- anova(lm(conc ~ uptake, CO2)) >> afit$P > [1] 2.905607e-06 NA > Warning message: > In `$.data.frame`(afit, P) : Name partially matched in data frameI think it's reasonable to emit a warning in that case, although it would be more useful to say: Warning message: P partially matched to `Pr(>|Chi|)` in data frame Hadley -- Chief Scientist, RStudio http://had.co.nz/
Peter Meilstrup
2013-Jul-02 03:56 UTC
[Rd] Problem with anova and the new abbreviation restrictions
On Mon, Jul 1, 2013 at 1:51 PM, Terry Therneau <therneau@mayo.edu> wrote:> > afit <- anova(lm(conc ~ uptake, CO2)) > > afit$P > [1] 2.905607e-06 NA > Warning message: > In `$.data.frame`(afit, P) : Name partially matched in data frame > > afit$Pr(>F) > Error: unexpected '>' in "afit$Pr(>" > > The second is a result of allowing TAB completion of the name. >I also noticed that tab--completion of afit$`P gives nothing useful. Tab-completion should definitely insert backticks when necessary and interpret backticks when they are present. Peter [[alternative HTML version deleted]]