# 2019 データ解析基礎論a DAA02

```x<-matrix(1:8, nrow=2)
x<-matrix(1:8, nrow=2,byrow=T)
data01<-data.frame(score = c(2,4,3,4),
dose = c(rep(10,2),rep(100,2)),
condition = rep(c('exp','control'),2))

mean(dat\$shoesize[dat\$gender == "M"])
mean(dat\$shoesize[dat\$gender == "F"])
mean(dat\$shoesize[dat\$h > 180])

v1 = seq(-3,3,0.1)
v2 = v1^2
plot(x = v1, y = v2)
plot(v1, v2, col = 'red')

plot(v1, v2, main = "THIS IS THE TITLE", cex.lab = 1.5,
xlab = "Label for X-axis",ylab = "Label for Y-axis")

plot(v1, v2, col = "blue", type = "o", lty = 2, pch = 19,
cex.lab = 1.5, lwd = 3, main = "Y=X*X", xlab = "X",
ylab="X*X", xlim=c(-3.5,3.5), ylim=c(-0.5, 10))

hist(dat\$h)
hist(dat\$h, breaks = 20, main = “Histogram of Height”,
xlab = "Height", col = 'blue', xlim = c(140, 190))

dens<-density(dat\$h);
hist(dat\$h, main = "Histogram of Height", xlab = "Height",
xlim = c(140,190), probability = T)
lines(dens, lwd = 2, col = ‘red’, lty=2)

plot(v1, v2, col = "blue", type = "l",
pch = 19, cex.lab = 1.5, lwd = 3,
xlab = "X", ylab="f(X)",
xlim=c(-3.5,3.5), ylim=c(-0.5, 10))
lines(v1, v1^3, col='red',lwd = 3)
legend("bottomright", c("x^2","x^3"), col=c('blue','red'), lwd=2)

boxplot(dat\$h ~ dat\$gender,
main="Distribution of Height by Gender",
ylab="Gender", xlab="Height", col=c('blue','cyan'),
ylim=c(140,190), horizontal=T)

interaction.plot(dat\$gender,
dat\$affil,
dat\$h,
pch=c(20,20),
col=c("skyblue","orange"),
xlab="gender", ylab="height",
lwd=3,type='b',cex=2,
trace.label="Affiliation")

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)

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')

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))
lines(dat[dat\$gender=='M',]\$shoesize,dat[dat\$gender=='M',]\$h,
type = 'p', pch = 15, col = 'green')
legend("topleft", c('Female','Male'), pch =c(19,15),
col = c('blue','green'), cex = 1.5)
```