dat<-read.table("http://www.matsuka.info/data_folder/aov01.txt")
par(mfrow=c(1,2))
hist(dat[dat$gender=='F',]$h, main="Dist. of Height for Female Participants",
xlab="Height", xlim=c(140,190), probability=T)
dens.F = density(dat[dat$gender=='F',]$h)
lines(dens.F, col='blue',lwd=2)
hist(dat[dat$gender=="M",]$h,
main="Dist. of Height for Male Participants",
xlab="Height", xlim=c(140,190), probability=T,ylim=c(0,0.08))
dens.M = density(dat[dat$gender=='M',]$h)
lines(dens.M, col='green', lwd=2)
par(mfrow=c(1,1))
plot(dens.F,col='blue',lwd=2, ylab='density', xlim=c(140,190),
main="Dist. of Height by gender",xlab='Height')
lines(dens.M,col='green',lwd=2)
legend("topleft", c('Female','Male'), col=c('blue','green'), cex=1.5,lwd=2)
text(x = 157.5, y = 0.04, 'Female', col='blue', cex=2)
text(x = 170, y = 0.04,'Male', col='green', cex=2)
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='green');
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))
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')
Related