weight <- c(50,55,63,55,67,43,52)
high <- c(150,160,170,175,150,153,165)
mean(weight) #平均數
## [1] 55
median(weight) #中位數
## [1] 55
as.numeric(names(table(weight)))[which.max(table(weight))] #眾數
## [1] 55
sd(weight) #standard deviation
## [1] 8.020806
var(weight) #varianc
## [1] 64.33333
plot(weight,high,
pch=20,
col= "#009393",
xlab="體重",
ylab="身高",
main="班級的身高體重")

# Load ggplot2
library(ggplot2)
# Load ggplot2
library(ggplot2)
# Create data
data <- data.frame(
name=c("蛤","?","??","???","????","?????") ,
value=c(50,55,63,55,67,43)
)
# Barplot
ggplot(data, aes(x=name, y=value)) +
geom_bar(stat = "identity", width=0.2, fill="#00CACA")

data<- c(50,23,35,48)
labels <- c("!","!!","!!!","!!!!")
pie(data,labels,main ="學生的比例", col=heat.colors(length(data)))
