# traditional biplot from {ca}
library(ca)
data("author")
author_ca <- ca(author)
plot(author_ca)
# alternative plot with {mclm} tools
r_pc <- row_pcoord(author_ca)
c_pc <- col_pcoord(author_ca)
xlim <- xlim4ca(author_ca)
ylim <- ylim4ca(author_ca)
author_names <- as.factor(gsub(
"^.*?\\((.*?)\\)$", "\\1",
rownames(author), perl = TRUE))
plot(r_pc[,1], r_pc[,2], pch = 18,
xlim = xlim, ylim = ylim, xlab = "", ylab = "",
main = "authors and their alphabet",
col = as.numeric(author_names))
abline(h = 0, col = "gray", lty = 3)
abline(v = 0, col = "gray", lty = 3)
text(c_pc[,1], c_pc[,2], colnames(author), col = "gray")
legend("topright",
legend = levels(author_names),
pch = rep(18, length(levels(author_names))),
col = 1:length(levels(author_names)),
title = "authors")
Run the code above in your browser using DataLab