如何使用mtcars数据集中的隐藏列标记R中的散点图?
我已经在R中使用mtcars数据集绘制了散点图,mpg在x轴上,wt在y轴上。我现在尝试根据第一列(汽车模型)标记数据点,但由于该列没有任何名称,因此无法标记绘图如何使用mtcars数据集中的隐藏列标记R中的散点图?,r,R,我已经在R中使用mtcars数据集绘制了散点图,mpg在x轴上,wt在y轴上。我现在尝试根据第一列(汽车模型)标记数据点,但由于该列没有任何名称,因此无法标记绘图 attach(mtcars) plot(mpg,wt, xlab = "Miles per Gallon", ylab = "Weight of car (in metric tonnes)", col = "blue" , pch = 19) text(mpg,wt, labels = "?"
attach(mtcars)
plot(mpg,wt,
xlab = "Miles per Gallon",
ylab = "Weight of car (in metric tonnes)",
col = "blue" , pch = 19)
text(mpg,wt, labels = "?" , cex = 0.7)
使用行名(mtcars)
fo
fo <- wt ~ mpg
plot(fo, mtcars,
xlab = "Miles per Gallon",
ylab = "Weight of car (in metric tonnes)",
col = "blue" , pch = 19)
text(fo, mtcars, labels = rownames(mtcars) , cex = 0.7)