資料匯入及基本
將資料複製到文件下面(R的根目錄)
匯入資料,匯入資料命名為My_data
My_data <- read.csv("wisc_bc_data.csv")
查看資料內容
View(My_data)
安裝套件:以ggplot2為例
install.packages("ggplot2")
執行套件
library("ggplot2")
載入R的內建範例_鳩尾花資料_iris
將名稱命名為IRIS
IRIS <- as.data.frame(iris)
利用IRIS資料,練習繪製各種圖形
qplot(data = IRIS , x=IRIS$Petal.Length , geom = "bar")
qplot(data = IRIS , IRIS$Sepal.Length , IRIS$Petal.Length)
qplot(data = IRIS , x=IRIS$Petal.Length , y=IRIS$Sepal.Width , geom = "point")
qplot(data = IRIS , x=IRIS$Petal.Length , y=IRIS$Sepal.Width , geom = "smooth")
qplot(data = IRIS , x=IRIS$Petal.Length , y=IRIS$Sepal.Width , geom = "path")
qplot(data = IRIS , x=IRIS$Petal.Length , y=IRIS$Sepal.Width , geom = "line")
qplot(data = IRIS , x=IRIS$Petal.Length , geom = "histogram")
qplot(data = IRIS , x=IRIS$Species , y=IRIS$Sepal.Width , geom = "boxplot")
繪製兩個重疊表格
qplot(data = IRIS , x=IRIS$Petal.Length , y=IRIS$Sepal.Width , geom = c("point" , "smooth"))
資料篩選
Sepal.Length>3
Sepal.Length>3
Sepal.Width>2
Petal.Width>2
data_select <- IRIS[IRIS$Sepal.Length>3 & IRIS$Sepal.Length>3 & IRIS$Sepal.Width > 2 & IRIS$Petal.Width>2 , ]
View(data_select)