1

In the package nnet, the following example is given:

# or
ird <- data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]),
        species = factor(c(rep("s",50), rep("c", 50), rep("v", 50))))
ir.nn2 <- nnet(species ~ ., data = ird, subset = samp, size = 2, rang = 0.1,
               decay = 5e-4, maxit = 200)
table(ird$species[-samp], predict(ir.nn2, ird[-samp,], type = "class"))

I do not understand how this part works: species ~ ., I understand it is some kind of formula that is passed as argument but I do not know where to search for more information about the syntax of formulaes and what the . will represent.

Please close this question if it is a duplicate, I could not find the same question.

BlueTrin
  • 9,610
  • 12
  • 49
  • 78

1 Answers1

2

. represents all the features/columns except the outcome (which is written on the RHS of ~). More info can be found here ?formula

Basically, for the iris3 data set, the formula

species ~ . 

is equivalent to

species ~ Sepal L. + Sepal W. + Petal L. + Petal W.
Nishanth
  • 6,932
  • 5
  • 26
  • 38