R言語:複数種のデータの簡単なプロット


x1 = 1:10
y1 = 11:20
categ1 = factor(c("A","A","B","B","A","A","B","A","B","A"))
plot(x1, y1, pch = c(2,20)[ categ1 ], col = c("blue","red")[ categ1 ])
legend("topleft", legend=levels(categ1), pch = c(2,20), col=c("blue","red"))