# matplotを簡単に使えるようにした関数 matplot2 <- function(df, lg.x=0.65, lg.y=1.0, col=1:6){ tb.y <- tapply(df[,2], list(as.numeric(rownames(df)), df[,3]), mean) tb.x <- matrix(rep(df[,1], ncol(tb.y)), ncol=ncol(tb.y)) matplot(tb.x, tb.y, col=col, xlab=colnames(df)[1], ylab=colnames(df)[2]) legend(max(df[,1])*lg.x, max(df[,2])*lg.y, paste(1:ncol(tb.y), colnames(tb.y), sep=":"), text.col=col) } # matplotもどき matplot3 <- function(df, ...){ col <- as.numeric(df[[3]]) pch <- as.character(col) plot(df[[1]], df[[2]], pch=pch, col=col) } # 使用方法 data(iris) data <- data.frame(iris[,1], iris[,3], iris[,5]) matplot2(data) matplot3(data)