《R语言实战》scatterplot()报错
以下是《R语言实战》(第2版)中的一段代码:
library(car)
scatterplot(mpg~wt|cyl,data = mtcars,lwd=2,span=0.75,
main="Scatter Plot of MPG vs. Weight by # Cylinders",
xlab = "Weight of Car (1bs/1000)",
ylab = "Miles Per Gallon",
legend.plot=T,
id.method="identify",
labels=row.names(mtcars),
boxplots="xy"
)
*运行后显示:
Error in axis(side = side, at = at, labels = labels, ...) :
'label'的值虽然是有了,但'at'的值却不存在
In addition: There were 11 warnings (use warnings() to see them)
具体warning信息以及显示图见附图
请问如何解决?
id.method="identify"问题
以下两段代码在设置这一参数后点击生成的图中的点都没有交互显示labels选项的设定值,请问这是怎么回事?如何修改?
library(car)
states<-as.data.frame(state.x77[,c("Murder","Population",
"Illiteracy","Income","Frost")])
fit<-lm(Murder~Population+Illiteracy+Income+Frost,data=states)
qqPlot(fit,labes=row.names(states),id.method="identify",simulate=T,main="Q-Q Plot")
library(car)
states<-as.data.frame(state.x77[,c("Murder","Population","Illiteracy","Income","Frost")])
fit<-lm(Murder~Population+Illiteracy+Income+Frost,data=states)
influencePlot(fit, id.method="identify" ,main="Influence Plot",
sub="Circle size is proportional to Cook's distance")