Possible Duplicate:
What does the period mean in the following R excerpt?
in the aggregate help file:
Dot notation:
aggregate(. ~ Species, data = iris, mean)
aggregate(len ~ ., data = ToothGrowth, mean)
What is meaning of .
here?
Possible Duplicate:
What does the period mean in the following R excerpt?
in the aggregate help file:
Dot notation:
aggregate(. ~ Species, data = iris, mean)
aggregate(len ~ ., data = ToothGrowth, mean)
What is meaning of .
here?
It means "all other variables." That is, those variables of the data which are not otherwise present in the formula.
In the first expression, these are Sepal.Length
, Sepal.Width
, Petal.Length
, Petal.Width
as can be seen by running the command:
aggregate(. ~ Species, data = iris, mean)
Species Sepal.Length Sepal.Width Petal.Length Petal.Width
1 setosa 5.006 3.428 1.462 0.246
2 versicolor 5.936 2.770 4.260 1.326
3 virginica 6.588 2.974 5.552 2.026
This statement is equivalent:
aggregate(cbind(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width) ~ Species, data = iris, mean)
From ?formula
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’.