This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.
par(mfrow = c(1, 2)) # 一列兩圖
statistics <- c(68, 85, 74, 88, 63, 78, 90, 80, 58, 63)
math <- c(85, 91, 74, 100, 82, 84, 78, 100, 51, 70)
hist(statistics,
main = "Statistics 成績直方圖",
xlab = "成績",
ylab = "人數",
col = "skyblue",
border = "black")
hist(math,
main = "Math 成績直方圖",
xlab = "成績",
ylab = "人數",
col = "lightgreen",
border = "black")
par(mfrow = c(1, 3))
statistics <- c(68, 85, 74, 88, 63, 78, 90, 80, 58, 63)
math <- c(85, 91, 74, 100, 82, 84, 78, 100, 51, 70)
hist(statistics,
main = "Statistics 成績直方圖",
xlab = "成績",
ylab = "人數",
col = "skyblue",
border = "black")
hist(math,
main = "Math 成績直方圖",
xlab = "成績",
ylab = "人數",
col = "lightgreen",
border = "black")
plot(statistics, math,
main = "Statistics vs Math 散佈圖",
xlab = "Statistics 成績",
ylab = "Math 成績",
pch = 19,
col = "darkorange")
par(mfrow = c(2, 2))
statistics <- c(68, 85, 74, 88, 63, 78, 90, 80, 58, 63)
math <- c(85, 91, 74, 100, 82, 84, 78, 100, 51, 70)
students <- paste0(“Student_”, 1:10)
total <- statistics + math
hist(statistics,
main = "Statistics 成績直方圖",
xlab = "成績",
ylab = "人數",
col = "skyblue",
border = "black")
hist(math,
main = "Math 成績直方圖",
xlab = "成績",
ylab = "人數",
col = "lightgreen",
border = "black")
plot(statistics, math,
main = "Statistics vs Math 散佈圖",
xlab = "Statistics 成績",
ylab = "Math 成績",
pch = 19,
col = "darkorange")
pie(total,
labels = students,
main = "每位學生總分圓餅圖",
col = rainbow(length(total)))
# 清空畫面,設為 2 列 3 圖
par(mfrow = c(2, 3))
statistics <- c(68, 85, 74, 88, 63, 78, 90, 80, 58, 63)
math <- c(85, 91, 74, 100, 82, 84, 78, 100, 51, 70)
students <- paste0(“Student_”, 1:10)
total <- statistics + math
hist(statistics,
main = "Statistics 成績直方圖",
xlab = "成績",
ylab = "人數",
col = "skyblue",
border = "black")
hist(math,
main = "Math 成績直方圖",
xlab = "成績",
ylab = "人數",
col = "lightgreen",
border = "black")
plot(statistics, math,
main = "Statistics vs Math 散佈圖",
xlab = "Statistics 成績",
ylab = "Math 成績",
pch = 19,
col = "darkorange")
pie(total,
labels = students,
main = "每位學生總分圓餅圖",
col = rainbow(length(total)))
plot(total,
type = "n",
xaxt = "n",
main = "總分棒棒糖圖",
xlab = "學生",
ylab = "總分",
ylim = c(0, max(total) + 10))
segments(x0 = 1:10, y0 = 0, x1 = 1:10, y1 = total, col = “steelblue”, lwd = 2)
points(1:10, total, pch = 16, col = “dark