如何将样本ID(行号)作为标签添加到此LDA图中的每个点?
library(MASS)
ldaobject <- lda(Species~., data=iris)
plot(ldaobject, panel = function(x, y, ...) points(x, y, ...),
col = as.integer(iris$Species), pch = 20)
答案 0 :(得分:4)
您可以在面板功能中使用text
:
library(MASS)
ldaobject <- lda(Species~., data=iris)
plot(ldaobject,
panel = function(x, y, ...) {
points(x, y, ...)
text(x,y,labels=seq_along(x),...) ## You change labels here
}
,
col = as.integer(iris$Species), pch = 20)