What is the syntax of the formula argument in R? -
this question has answer here:
- meaning of ~. (tilde dot) argument? 1 answer
in package nnet
, following example 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 not understand how part works: species ~ .
, understand kind of formula passed argument not know search more information syntax of formulaes , .
represent.
please close question if duplicate, not find same question.
.
represents features/columns except outcome (which written on rhs of ~
). more info can found here ?formula
basically, iris3
data set, formula
species ~ .
is equivalent to
species ~ sepal l. + sepal w. + petal l. + petal w.