这个 R 代码:
avector <- as.vector(top.links.added.overall$Amount)
x <- as.vector(top.links.added.overall[order(avector),])
x$Amount <- factor(x$Amount)
x$color[x$Amount == 100] <- "red"
x$color[x$Amount == 500] <- "blue"
x$color[x$Amount == 1000] <- "darkgreen"
dotchart(x$Amount,
labels = row.names(x),
cex=.7,
groups = x$Amount,
gcolor = "black",
color = x$color,
pch=19,
main = "Gas Mileage for Car Models\ngrouped by cylinder",
xlab = "Miles Per Gallon")
返回此错误:
Error in dotchart(x$Amount, labels = row.names(x), cex = 0.7, groups = x$Amount, :
'x' must be a numeric vector or matrix
这是 top.links.added.overall 的数据文件:
Amount,Name
1000,Google
500,Cnn
100,Yahoo
'x' 是一个向量,那么是什么导致了这个错误?