2015年3月7日 星期六

R語言下的視覺化

R語言下的視覺化

作者:楊為巽 Wei Hsun Yang


用ggplot2置作的圖表


ggplot2起手式



ggplot(data=..., aes(x=..., y=...))+geom_xxx(...)


先告訴ggplot說data從哪來
例如:ggplot(iris)

aes:圖上的元素和data的對應關係,簡單說,就是x軸和y軸各放什麼變數
例如:ggplot(iris, aes(x= Sepal.Length, y= Sepal.Width))



先畫個scatter plot吧

g <- ggplot(iris, aes(x= Sepal.Length, y= Sepal.Width))
g+ geom_point()





ggplot2 指令簡易版


如果覺得太難記,請看這裡