Skip to content
Prev 171197 / 398506 Next

why doesn't table() have a data=argument?

on 02/20/2009 09:11 AM Michael Friendly wrote:
xtabs and other functions (such as modeling and plot functions) that
include a 'data' argument have a formula based argument as the means by
which you indicate the columns of the data frame to be included.

These are then passed to model.frame() internally to create the data
frame to be used subsequently by the function. Since model.frame() is
evaluated within the environment of the data frame indicated by the
'data' argument if present, it is needed there.

It's always dangerous to say always, but in my experience, functions
that have a 'data' argument fit the above profile.

If table() had a formula method, then having a 'data' argument would
make sense.

HTH,

Marc Schwartz