#下載R與Rstudio
https://www.rstudio.com/products/rstudio/download/
#參考網頁
https://ithelp.ithome.com.tw/users/20103434/ironman/1056?page=1
https://sites.google.com/site/rlearningsite/home
#安裝ggplot2
install.packages("ggplot2")
library(ggplot2)
#定義資料
df = 檔案名稱
#繪製點狀圖
qplot(diamonds$carat, diamonds$price)
qplot(m$math, m$english)
#相關及圖示
ggplot(df, aes(x = english, y = math)) + geom_point()
# 依據不同間斷變項區別顏色
ggplot(df, aes(x = english, y = math)) + geom_point(aes(color = aid))
----------------------------------------------------------------
#著色
qplot(carat, price, data = diamonds.subset, color = color)
#形狀分布
qplot(carat, price, data = diamonds.subset, shape = cut)
#箱型圖
qplot(color, price / carat, data = diamonds, geom = "boxplot")
#直方圖
qplot(carat, data = diamonds, geom = "histogram")
#調整寬度
qplot(carat, data = diamonds, geom = "histogram",
binwidth = 0.5, xlim = c(0, 3))
#長條圖
qplot(color, data = diamonds, geom = "bar")
#時間序列
qplot(date, unemploy / pop, data = economics, geom = "line")