[R] How '.' is used?

(Ted Harding) Ted.Harding at manchester.ac.uk
Sun Aug 9 20:58:35 CEST 2009

On 09-Aug-09 16:53:32, Douglas Bates wrote:
> On Sun, Aug 9, 2009 at 11:32 AM, Ted
> Harding<Ted.Harding at manchester.ac.uk> wrote:
>> On 09-Aug-09 16:06:52, Peng Yu wrote:
>>> Hi,
>>> I know '.' is not a separator in R as in C++. I am wondering where it
>>> discusses the detailed usage of '.' in R. Can somebody point me a
>>> webpage, a manual or a book that discuss this?
>>> Regards,
>>> Peng
>> To the best of my knowledge, apart from its specific use as a
>> separator
>> between the integer and fractional parts of a number, "." has no
>> specific
>> use in R, and you can, for instance, use it just as you would use an
>> alphanumeric character in a name.
>> For instance, you could do
>> _. <- 1.2345
>> _.
>> _# [1] 1.2345
>> _. <- function(x) x^2
>> _.(12)
>> _# [1] 144
>> So, unless there is something I don't know about, there is hardly
>> anything to discuss about "the detailed usage of '.' in R"!
> The ',' character is one of the characters allowed in names, hence it
> can be used as you have suggested.  There are (at least) two special
> usages of the '.' in names.  Following the time-honoured Unix
> convention, names that begin with '.' are considered "hidden" names
> and not listed by ls() or objects() unless you set all.names = TRUE in
> the call.  Because of this convention it is inadvisable to use names
> starting with '.' except when you wish to avoid potential name
> conflicts.  The second special use of '.' in a name is in the
> construction of the names of S3 method functions.  The method for
> generic function "foo" applied to class "bar" is named "foo.bar".

As in "summary.glm", I suppose! However, this prompts a question.
In the first place, the construction of "summary.glm" from "summary"
and "glm" is, in the first instance, simply using "." in its basic
role as a permissible character in a name. Correct?

Next -- and this is the real question -- how does R parse the name
"summary.glm"? In my naivety, I simply suppose that it looks for
an available function whose name is "summary.glm" in just the
same way as it looks for "stopifnot", or for that matter "data.matrix"
which is not (as far as I know) a compound of a generic function
"data" applied to a class "matrix". Then "." would not have a special
(parseable) role in the name -- it is simply another "letter".

But when you do have such a function, like "summary.glm", does R
in fact parse it as "summary" then "glm" (i.e. look out for the
generic function "summary" and then specialise it to handle "glm").

As I say, I suppose not. And, if not, then the "special use" of
the character "." is simply a programmer's convention for the
construction of the name, and once the name exists the "." does
not have a special (parseable) significance for R.

Just seeking clarification ... !

E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 09-Aug-09                                       Time: 19:58:32
------------------------------ XFMail ------------------------------

More information about the R-help mailing list