I'm just reading the book "R in a Nutshell". And it seems as if I skipped the part where the "." as in "sample.formula" was explained.

> sample.formula <- as.formula(y~x1+x2)

Is sample an object with a field formula as in other languages? And if so, how can I find out, what other fields/functions this object has? (Type declaration)

EDIT: I just found another confusing use of the ".":

> svm(formula = is_spam~., data = spambase.training)

(the dot between ~., )

  • $\begingroup$ The dot you see with the is_spam~. command means that there are no explanatory variables. Typically with model formulas, you will see y~x, but if you have no x variable, y~. says to guess at the value of y using no other variables. This is the same as the model $y=\beta_0$ $\endgroup$ Commented May 12, 2011 at 20:06
  • 12
    $\begingroup$ @Christopher On the contrary, the . in the formula tells R to use all variables in the dataframe spambase.training (except is_spam) as predictors. The model $y = \beta_{0}$ is fit with y ~ 1. $\endgroup$
    – caracal
    Commented May 12, 2011 at 20:25
  • $\begingroup$ I didn't check sources beforehand. Thank you for the correction! $\endgroup$ Commented May 12, 2011 at 23:31
  • $\begingroup$ @caracal (+1) Wow I was just wondering how to do this. Thanks! $\endgroup$ Commented May 13, 2011 at 4:37

4 Answers 4


The dot can be used as in normal name. It has however additional special interpretation. Suppose we have an object with specific class:

 a <- list(b=1)
 class(a) <- "myclass"

Now declare myfunction as standard generic in the following way:

 myfunction <- function(x,...) UseMethod("myfunction")

Now declare the function

 myfunction.myclass <- function(x,...) x$b+1

Then the dot has special meaning. For all objects with class myclass calling


will actualy call function myfunction.myclass:

 > myfunction(a)
  [1] 2

This is used widely in R, the most apropriate example is function summary. Each class has its own summary function, so when you fit some model for example (which usually returns object with specific class), you need to invoke summary and it will call appropriate summary function for that specific model.

  • $\begingroup$ I am very surprised this answer was accepted and upvoted so much, because it doesn't answer the question at all! It refers to the ellipsis ... (which is a single lexeme, not a sequence of three different ones) as a "dot" whereas the question clearly means a dot . as used in formulas and names in an entirely different way, as correctly described in a contemporaneous answer by Chase. $\endgroup$
    – whuber
    Commented Jun 12, 2015 at 20:39
  • 3
    $\begingroup$ Well I do not refer to the ellipsis. I tried to explain that the dot is used for S3 method dispatch. The generic functions usually have ellipses, that is why I used them. If they are removed from the code, the answer would not change. I can only guess that I gave the answer before the edit, since I would give a different answer now after rereading the question body. $\endgroup$
    – mpiktas
    Commented Jun 12, 2015 at 21:14
  • 1
    $\begingroup$ Thank you for the explanation. I think the appearance of "..." two times misled me into believing you were referring to it as a "dot". $\endgroup$
    – whuber
    Commented Jun 12, 2015 at 23:13

Look at the help page for ?formula with regard to . Here's the relevant bits:

There are two special interpretations of . in a formula. The usual one is in the context of a data argument of model fitting functions and means ‘all columns not otherwise in the formula’: see terms.formula. In the context of update.formula, only, it means ‘what was previously in this part of the formula’.

Alternatively, the reshape and reshape2 packages use . and ... a bit differently (from ?cast):

There are a couple of special variables: "..." represents all other variables not used in the formula and "." represents no variable


There are some exceptions (S3 method dispatch), but generally it is simply used as legibility aid, and as such has no special meaning.

  • 2
    $\begingroup$ I would say the opposite - it has special meaning (the S3 dispatch you mention), but some old naming conventions caused function names that are not S3 generics to have names that include a .. That pertains to names of functions. As for names of (non-function) objects, then yes, there is no special meaning. $\endgroup$ Commented May 12, 2011 at 15:54
  • $\begingroup$ At the beginning of a name, a . makes the object invisible to ls() though. $\endgroup$
    – caracal
    Commented May 12, 2011 at 20:48

The dot in sample.formula doesn't separate sample from formula, other than visually. It is just a variable name. R variables names can consist of alphanumerics and dot (.) and underscore (_) with one exception. Here is the actual rule:

"A syntactically valid name consists of letters, numbers and the dot or underline characters and starts with a letter or the dot not followed by a number. Names such as ".2way" are not valid, and neither are the reserved words."

The second case (i.e., the case of is_spam~.) is different and is explained above.


Not the answer you're looking for? Browse other questions tagged or ask your own question.