>RE::VISION CRM

R 데이터 분석

[R분석] 프로야구 KBO 타자 성적과 나이의 관계

YONG_X 2018. 9. 28. 15:27


hit5 <- read.csv("https://t1.daumcdn.net/cfile/blog/999FB3335BADBEDC24?download")

hit5$age <- c(30, 20, 28, 31, 30, 32, 37, 32,
37, 34, 36, 30,
30, 30, 28, 25, 28, 32, 28,
25, 28, 33, 32, 28,
29, 29, 28, 33, 34, 31, 39,
30, 29, 35, 29, 28,
26, 34,  31, 33, 28, 31, 22,
29, 29, 28, 29, 19,
31, 33, 33, 28, 19, 31, 34,
28, 28, 31, 27, 24,
31)

plot(hit5$age, hit5$TB,
  pch=19, col="steelblue", cex=1.5,
  main="나이와 타자 성적",
  xlab="AGE", ylab="TB")
hit51 <- hit5[hit5$XR/hit5$PA>0.18,]
points(hit51$age, hit51$TB,
  pch=19, col="red", cex=1.5)
text(hit51$age, hit51$TB,
  pos=3, labels=hit51$name)
lines(lowess(hit5$TB~hit5$age), lwd=2, lty=3)


boxplot(hit5$TB~hit5$age)


plot(hit5$age, hit5$TB,
  pch=19, col="steelblue", cex=1.5,
  main="프로야구 타자 - 나이와 성적",
  sub="red: XR/PA>0.18",
  xlab="AGE", ylab="TB")
hit51 <- hit5[hit5$XR/hit5$PA>0.18,]
points(hit51$age, hit51$TB,
  pch=19, col="red", cex=1.5)
text(hit5$age, hit5$TB,
  pos=3, labels=hit5$name)
lines(lowess(hit5$TB~hit5$age), lwd=2, lty=3)