'R Error in `[.data.frame`(data, , model.list$variables) : undefined columns selected

I'm trying to use neuralnet command in R, but i keep getting this error: Error in [.data.frame(data, , model.list$variables) : undefined columns selected

I tried specifying columns to see if it's the matter of accessibility (pm$category etc), but it keeps giving me the same error. It shouldn't be necessary as the dataset is already attached, but I'm not sure what else could be the reason. This is my code:


pm <- read.csv("FILENAME")
attach(pm)

trainset <- X[1:640, ]
testset <- X[641:800, ]

#Neural Network
library(neuralnet)

nn <- neuralnet(category~camera+location+photographer, data=trainset, hidden=c(2,1), linear.output=FALSE, threshold=0.01)
nn$result.matrix

r


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source