Skip to content
Prev 166921 / 398502 Next

indexing question

There are real examples; they are all fairly obscure.  It can't be a big problem because the standard formal argument name for a data frame in modelling and graphics functions is 'data'.  That's actually a more serious problem than the function called data() -- having local and global variables with the same name won't confuse R, but it can easily confuse you.

Possibilities for R getting confused include
  1. The functions for environment access by name, eg exists(), get(), don't by default check the type of the argument.
  2. bquote() and substitute() substitute before evaluating and could get confused.

There used to be real problems in S when certain function names were used as data names.  Then there was a period of aversive conditioning by irritating warnings. As a result, I still avoid 'c' and 't' as variable names.

You could call your data frames 'df' -- many of the people who complain about 'data' don't realise that df() is the density function of the F distribution :)

      -thomas
On Tue, 13 Jan 2009, Ista Zahn wrote:

            
Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle