S <- c(68,85,74,88,63,78,90,80,58,63)
M <- c(85,91,74,100,82,84,78,100,51,70)
plot(S,M,
pch = 23,
col= "skyblue",
main ="統計成績與數學成績之散佈圖",
xlab ="統計",
ylab ="數學")

hist(M,
col= "lightyellow",
main ="班上的體重與身高",
xlab ="體重",
ylab ="次數")

# Load ggplot2
library(ggplot2)
# Create data
data <- data.frame(
name=c("娛樂休閒","知識閱讀","體育競技","科學創新","公益活動") ,
value=c(185,82,36,28,25)
)
# Bar plot
ggplot(data, aes(x=name, y=value)) +
geom_bar(stat = "identity")

data2<- c(185,82,36,28,25)
labels <- c("娛樂休閒","知識閱讀","體育競技","科學創新","公益活動")
pie(data2,labels,main ="社團類型", col=heat.colors(length(data)))

# Library
library(ggplot2)
# plot
ggplot(data, aes(x=name, y=value)) +
geom_segment( aes(x=name, xend=name, y=0, yend=value)) +
geom_point( size=5, color="red", fill=alpha("orange", 0.3), alpha=0.7, shape=21, stroke=2)

v <-c(84,63,61,49,89,51,59,53,79,91)
stem(v)
##
## The decimal point is 1 digit(s) to the right of the |
##
## 4 | 9
## 5 | 139
## 6 | 13
## 7 | 9
## 8 | 49
## 9 | 1
J <-c(84,63,61,49,89,51,59,53,79,91)
mean(v)
## [1] 67.9
median(v)
## [1] 62
as.numeric(names(table(J)))[which.max(table(J))]
## [1] 49
sd(v)
## [1] 16.25115
var(v)
## [1] 264.1
Q1 <- quantile(J, 1 / 4)
Q2 <- quantile(J, 2 / 4)
Q3 <- quantile(J, 3 / 4)
P1 <- quantile(J, 1 / 10)
P2 <- quantile(J, 2 / 10)
P3 <- quantile(J, 3 / 10)
P5 <- quantile(J, 5 / 10)
Q1
## 25%
## 54.5
Q3
## 75%
## 82.75