Getting an error in function call r : Missing argument to function call

3153 views r
-1

enter image description here

I am getting above mentioned error in R while creating trian data set.

Code: reg_train_df <- as.data.frame(train_df[,c("name", "price", "abtest", "vehicleType", "yearofRegistration", "gearbox", "powerPS", "model", "kilometer", "monthofRegistration", "fuelType", "brand", "notRepairedDamage", "postalCode", #"Log.price" )]) ```

Error:

Error in c("name", "price", "abtest", "vehicleType", "yearofRegistration", : argument 15 is empty

Show Traceback:

3. [.data.frame(train_df, , c("name", "price", "abtest", "vehicleType", "yearofRegistration", "gearbox", "powerPS", "model", "kilometer", "monthofRegistration", "fuelType", "brand", "notRepairedDamage", "postalCode", ))

2. train_df[, c("name", "price", "abtest", "vehicleType", "yearofRegistration", "gearbox", "powerPS", "model", "kilometer", "monthofRegistration", "fuelType", "brand", "notRepairedDamage", "postalCode", )]

1. as.data.frame(train_df[, c("name", "price", "abtest", "vehicleType", "yearofRegistration", "gearbox", "powerPS", "model", "kilometer", "monthofRegistration", "fuelType", "brand", "notRepairedDamage", "postalCode", )])

Please help to get rid of this error

answered question

1 Answer

9

It is because you forgot to remove the last comma.

For example this line

reg_train_df <- as.data.frame(train_df[,c("name", "price", "abtest", "vehicleType", "yearofRegistration", "gearbox", "powerPS", "model", "kilometer", "monthofRegistration", "fuelType", "brand", "notRepairedDamage", "postalCode", #"Log.price" )])

Should become:

   reg_train_df <- as.data.frame(train_df[,c("name", "price", "abtest", "vehicleType", "yearofRegistration", "gearbox", "powerPS", "model", "kilometer", "monthofRegistration", "fuelType", "brand", "notRepairedDamage", "postalCode" #"Log.price" 
    )]) 

posted this

Have an answer?

JD

Please login first before posting an answer.