2019 データ解析基礎論A DAA04

dat<- read.csv("http://www.matsuka.info/data_folder/datWA01.txt")
plot(dat$shoesize, dat$h, main="Relationship b/w shoesize and height",
     xlab = "shoesize", ylab="height", pch=19, col="red")
txt = paste("r =", round(cor(dat$shoesize,dat$h), 4))
text(22, 175, txt, cex = 1.5)
abline(h = mean(dat$h), col='blue');
abline(v = mean(dat$shoesize), col='darkgreen');
text(x = 21, y = mean(dat$h)+3,
        paste("mean height =", round(mean(dat$h),2)),
        col="blue",adj = 0)

text(x = mean(dat$shoesize)+0.2, y = 145,
        paste("mean shoesize =", round(mean(dat$shoesize),2)),
        col="darkgreen",adj = 0)

abline(lm(dat$h~dat$shoesize), lty=2, lwd=2)

plot(dat[dat$gender=='F',]$shoesize, dat[dat$gender=='F',]$h,
     main="Relationship b/w shoesize and height", xlab='shoesize', ylab='height',
     cex.lab=1.5, pch=19, col='blue', xlim=c(20,29), ylim=c(140,190))
plot(dat[dat$gender=='M',]$shoesize, dat[dat$gender=='M',]$h,
     main="Relationship b/w shoesize and height", xlab='shoesize', ylab='height',
     cex.lab=1.5, pch=15, col='green', xlim=c(20,29), ylim=c(140,190))

plot(dat[dat$gender=='F',]$shoesize, dat[dat$gender=='F',]$h,
     main="Relationship b/w shoesize and height", xlab='shoesize', ylab='height',
     cex.lab=1.5, pch=19, col='blue', xlim=c(20,29), ylim=c(140,190))
points(dat[dat$gender=='M',]$shoesize,dat[dat$gender=='M',]$h,
       pch = 15, col = 'green')
legend("topleft", c('Female','Male'), pch =c(19,15),
       col = c('blue','green'), cex = 1.5)

dat<-read.csv("http://www.matsuka.info/data_folder/tdkReg01.csv")
plot(dat, pch=20, col='blue')

dat.pca<-read.table("http://www.matsuka.info/data_folder/tdkPCA01.txt")
plot(dat.pca, pch = rownames(dat.pca), cex = 1.7, col = "blue")

dat<-read.table("http://www.matsuka.info/data_folder/aov01.txt",header=T)
summary(dat)
dat.meter = dat[,1:2]*0.01
dat.h.ext5 = dat$h+5
hANDshoe = dat$h+dat$shoesize
dat.h.meter.ext5 = dat$h*0.01+0.05