rtype-conversionnnet

R_function Nnet_How can I solve the following error "the object (list) can not be automatically converted in integer"?


I am trying to use a neural network algorithm to solve a statistical problem. When I call the function Nnet (software R) with the following parameters :

rn=nnet(resignation~., data=T[,-1], entropy=T, size=5, decay=1, MaxNWts=3000, maxit=1000)

I have the error below, and I don't succeed to understand the meaning of this error and how to solve it:

weights: 2656

Error in nnet.default(x, y, w, ...) : l'objet (list) ne peut être converti automatiquement en un type 'integer'

Error in nnet.default(x, y, w, ...) : the object (list) can not be automatically converted to an 'integer' type

Could you please help me ?

I remain available for any further information Thanks


Solution

  • It appears that the main problem is the fact that you use the name T as your data frame name. As a consequence, the value received by the entropy argument is a list (data frames can be seen as lists in R) instead of a boolean (or integer). To make it work, run this instead:

    rn=nnet(Species~., data=T[,-1], entropy=TRUE, size=5, decay=1, MaxNWts=3000, maxit=1000)
    

    N.B: I would suggest you not to use T as a variable name.