Statistic <- c(68,85,74,88,63,78,90,80,58,63)
Math <- c(85,91,74,100,82,84,78,100,51,70)
plot(Statistic,Math,
pch = 17,
col= "blue",
main ="Statistic and Math",
xlab ="Statistic",
ylab ="Math")

hist(Statistic,
col= "gray",
main ="Statistic and Math",
xlab ="Statistic",
ylab ="Math")

社團類型 <- c(5,4,3,2,1)
次數 <- c(185,82,36,28,25)
mean(社團類型)
## [1] 3
# Load ggplot2
library(ggplot2)
# Load ggplot2
library(ggplot2)
# Create data
data <- data.frame(
社團類型=c("娛樂休閒","知識閱讀","體育競技","科學創新","公益活動") ,
次數=c(185,82,36,28,25)
)
# Barplot
ggplot(data, aes(x=社團類型, y=次數)) +
geom_bar(stat = "identity", width=0.4, fill="lightyellow")

次數<- c(50,23,35,48)
社團類型 <- c("娛樂休閒","知識閱讀","體育競技","科學創新","公益活動")
# Data frame
data<- c(50,23,35,48)
labels <- c("娛樂休閒","知識閱讀","體育競技","科學創新","公益活動")
pie(data,labels,main ="大學生最喜歡的社團的參加次數分配表", col=heat.colors(length(data)))

library(ggplot2)
# Create data
data <- data.frame(
社團名稱=c("公益活動","科學創新","體育競技","知識閱讀","娛樂休閒"),
人數=c(25,28,36,82,185)
)
ggplot(data, aes(x=社團名稱, y=人數)) +
geom_segment( aes(x=社團名稱, xend=社團名稱, y=0, yend=人數), color="skyblue") +
geom_point( color="blue", size=4, alpha=0.6) +
theme_light() +
coord_flip() +
theme(
panel.grid.major.y = element_blank(),
panel.border = element_blank(),
axis.ticks.y = element_blank()
)

getwd()
## [1] "C:/Users/wenzao/Desktop"
data <- read.csv("期中考試資料.csv")
stem(data$Japanese)
##
## The decimal point is 1 digit(s) to the right of the |
##
## 4 | 9
## 5 | 139
## 6 | 13
## 7 | 9
## 8 | 49
## 9 | 1
mean(data$Japanese) #平均數
## [1] 67.9
median(data$Japanese) #中位數
## [1] 62
as.numeric(names(table(data$Japanese)))[which.max(table(data$Japanese))] #眾數
## [1] 49
sd(data$Japanese)#標準差
## [1] 16.25115
var(data$Japanese)#變異數
## [1] 264.1
Q1 <- quantile(data$Japanese, 1 / 4) #第一四分位數
Q3 <- quantile(data$Japanese, 3 / 4) #第三四分位數
Q1
## 25%
## 54.5
Q3
## 75%
## 82.75