DNN was performed using the neuralnet function. However, if I enter medv ~., In the formula parameter in the neuralnet function as below, the following error appears.
library("MASS")
data("Boston", package="MASS")
data<-Boston
keeps<-c("crim","indus","nox","rm","age","dis","tax","ptratio","lstat","medv")
data<-data[,keeps]
set.seed(2016)
train<-sample(1:nrow(data),400,FALSE)
fit<-neuralnet(medv~.,data=data[train,],hidden=c(10,12,20),algorithm="rprop+",err.fct="sse",
act.fct="logistic",threshold=0.1,linear.output = TRUE)
Error in terms.formula(formula) :
formula 안에 '.'가 사용되었는데 'data' 인자가 없습니다
However, there is no problem if I input the following explanatory variables.
fit<-neuralnet(medv~crim+indus+nox+rm+age+dis+tax+ptratio+lstat, data=data[train,],hidden=c(10,12,20),algorithm="rprop+",err.fct="sse",
act.fct="logistic",threshold=0.1,linear.output = TRUE)
If there are a lot of explanatory variables, it is impossible to write them one by one. what's the problem? and what can i do to consider all variables as short code like medv~. .