【发布时间】:2017-08-13 22:02:33
【问题描述】:
我一直在尝试根据最后一个类名来支持数据帧。
我有这个数据框
#FIll the data frame
df = read.table("https://archive.ics.uci.edu/ml/machine-learning-databases/car/car.data",
sep=",",
col.names=c("buying", "maint", "doors", "persons", "lug_boot", "safety", ""),
fill=TRUE,
strip.white=TRUE)
lastColName <- colnames(df)[ncol(df)]
...
model <- svm(lastColName~.,
data = df,
kernel="polynomial",
degree = degree,
type = "C-classification",
cost = cost)
我收到的是 NULL 或 Error in model.frame.default(formula = str(lastColName) ~ ., data = df1, : invalid type (NULL) for variable 'str(lastColName)'。我知道NULL 在列没有名称时到达。我不明白另一个错误,因为它是最后一列名称..
有什么想法吗?
【问题讨论】: