Skip to content

write.table

4 messages · Brian Ripley, Peter Dalgaard, Robert Gentleman +1 more

#
The argument is called `check.names', and has description

check.names: if `TRUE' then the names of the variables in the data
          frame are checked to ensure that they are valid variable
          names.  If necessary they are adjusted (by `make.names') so
          that they are.

So `make.names' should be renamed as `make.identifiers'.  That is
described as

make.names               package:base               R Documentation

Make Legal R Names Out of Strings

Description:

     Make legal R names out of every `names[i]' string. Invalid
     characters are translated to `"."'.


More plausibly, you are proposing a new distinction ....
1 day later
#
Prof Brian Ripley <ripley@stats.ox.ac.uk> writes:
Hmm. The current distinction would seem to be between "names" and
"legal R names" or "valid variable names", of which certainly the
latter is misleading since you can easily have variables with weird
names like "[<-". But you're probably right that we are to some extent
stuck with existing terminology, here and elsewhere. I think I would
want to push a convention of using "R names" for the syntactical
entities, then.
#
If anyone does find the time to delve into the naming of columns, one
thing that would be pretty nice is if the I() operator was stripped. 
It, and possibly some other special operators, probably shouldn't be
propagate. They really are about handling rather than naming and this
causes some minor annoyances when complex objects are put into dataframes.
#
The original S language authors shoulder the blame here, if there
maybe was a way to make the distinctions clearer by choosing
terminology better.  Being stuck with a vague use of `name', let me
suggest something roughly as follows.

(By the way, should this be on the FAQ?  I didn't see it there.)

The term `name' is used in four different (but related) ways in the
language:

1.  A `syntactic name' is a string the parser interprets as this type
    of expression.  It consists of letters, numbers, and the dot
    character and starts with a letter or the dot.

2.  An `object name' is a string associated with an object that is
    assigned in an expression either by having the object name on the
    left of an assignment operation or as an argument to the `assign'
    function.  It is usually a syntactic name as well, but can be any
    non-empty string if it is quoted (and it's always quoted in the
    call to `assign').

3.  An `argument name' is what appears to the left of the equals sign
    when supplying an argument in a function call (for example,
    `f(trim=.5)').  Argument names are also usually syntactic names,
    but again can be anything if they are quoted.

4. A `file name' is a string identifying a file in the operating
   system for reading, writing, etc.  It really has nothing much to do
   with names in the language, but it's traditional to call these
   strings file `names'.

I'd slightly discourage using the term "R name" because there is
nothing really R-dependent here.

There are some more details one can mention, such as that
non-syntactic argument names are usually only going to be matched by
"..." since the parser requires syntactic names for formal arguments.
But such details probably will only confuse if put in the FAQ.

John