What is the meaning. in aggregate function?

Possible duplicate:
What does the period in the next fragment of R mean?

in the summary help file:

Dot notation: aggregate(. ~ Species, data = iris, mean) aggregate(len ~ ., data = ToothGrowth, mean) 

What does it mean here . ?

+4
source share
2 answers

This means "all other variables." That is, those data variables that are not otherwise present in the formula.

In the first expression, this is Sepal.Length , Sepal.Width , Petal.Length , Petal.Width , as can be seen from 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 to:

 aggregate(cbind(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width) ~ Species, data = iris, mean) 
+6
source

From ?formula

There are two special interpretations. ' in the formula. usual - in the context of the "argument of modeling data of the function and means" all columns that are not related to the formula: see "terms.formula. In the context of 'update.formula, only this means" what was earlier in this part of the formula.

+6
source

All Articles