ONLY DO WHAT ONLY YOU CAN DO

こけたら立ちなはれ 立ったら歩きなはれ

R で 散布図 確率密度図 ~少年サッカー データ分析~

散布図

g <- ggplot(d4, aes(x=d4$"奪取",y=d4$"X10分あたりの得失",color=d4$"勝敗",fill=d4$"勝敗")) 
g <- g+geom_point(size=1, alpha=0.5)
plot(g)

f:id:fornext1119:20180131121151p:plain

回帰直線を引いてみる

g <- ggplot(d4, aes(x=d4$"奪取",y=d4$"X10分あたりの得失")) 
g <- g + geom_point(size=1, alpha=0.5,aes(colour= d4$"勝敗"))
g <- g + stat_smooth(method = "lm")
plot(g)

f:id:fornext1119:20180131122132p:plain

ヒストグラム

g <- ggplot(d4)
g <- g + geom_histogram(aes(x=d4$"X10分あたりの得失",colour= d4$"勝敗", fill=d4$"勝敗"), binwidth=0.25, alpha=0.2, position="identity")
g <- g + xlab("X10分あたりの得失")
g <- g + ylab("試合数")
print(g)

f:id:fornext1119:20180131123255p:plain

確率密度

g <- ggplot(d4, aes(x=d4$"X10分あたりの得失", colour=d4$"勝敗", fill=d4$"勝敗"))
g <- g + geom_density(stat="density", position="identity", alpha = 0.5)
plot(g)

ヒストグラムよりわかりやすいと思ったけど、何か違和感
(題材が悪かった...)
f:id:fornext1119:20180131122759p:plain