创建trian数据集时,我在R中遇到上述错误。
代码:
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 in c("name", "price", "abtest", "vehicleType", "yearofRegistration", : argument 15 is empty
显示回溯:
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", )])
请帮助摆脱该错误
答案 0 :(得分:1)
这是因为您忘记删除最后一个逗号。
例如这行
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" )])
应成为:
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"
)])