unable to resolve error - Error in `[.data.frame`(data, , model.list$variables) : undefined columns selected

my code is as follows : -

Training_Electricity_Data_Set_16_21x_Neural_Model = neuralnet (Training_Electricity_Data_Set_16_21x$Monthy KWHN ~ Training_Electricity_Data_Set_16_21x$Seating CapacityN + Training_Electricity_Data_Set_16_21x$AreaN + Training_Electricity_Data_Set_16_21x$OccupancyN + Training_Electricity_Data_Set_16_21x$CDDN, Training_Electricity_Data_Set_16_21x, hidden = 2, err.fct = "sse", linear.output = TRUE)

Error is as follows : -

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

unable to solve error , please help & advise ...

Hello @Hiteshsingal ,
your problem is (or at least starts with) data fields (columns) with spaces in the field name.
Try to avoid this.
However if you need to use such a data.frame use backquotes (`) to indicate the fields you need.
See e.g.

Training_Electricity_Data_Set_16_21x <- data.frame(
  KWHN = 1:4,
  CapacityN = 1:4
)
names(Training_Electricity_Data_Set_16_21x) <- c("Monthy KWHN","Seating CapacityN")

print(Training_Electricity_Data_Set_16_21x)
#>   Monthy KWHN Seating CapacityN
#> 1           1                 1
#> 2           2                 2
#> 3           3                 3
#> 4           4                 4

print(Training_Electricity_Data_Set_16_21x$`Monthy KWHN`)
#> [1] 1 2 3 4
Created on 2021-10-11 by the reprex package (v2.0.0)

Thanks @ HanOostdijk

You solved my problem

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.