title: “Untitled” output: html_document date: “2024-11-07”
age <- c(20,21,23,55,67,52)
high <- c(150,160,170,175,150,153)
mean(age) #年齡的平均數
## [1] 39.66667
Q1 <- quantile(age, 1 / 4 )
Q2 <- quantile(age, 2 / 4 )
median(age)
## [1] 37.5
plot(age,high)
plot(age,high,
pch = 17,
col= "skyblue",
main ="班上的體重與身高",
xlab ="體重",
ylab ="身高")
hist(age,
col= "lightyellow",
main ="班上的體重與身高",
xlab ="體重",
ylab ="次數")
library(ggplot2)
# Create data
data <- data.frame(
type=c("eso","osn","eo") ,
value=c(3,12,5)
)
# Barplot
ggplot(data, aes(x=type, y=value)) +
geom_bar(stat = "identity", width=0.2, fill="yellow")
data<- c(50,23,35,48)
labels <- c("英文系","法文系","德文","翻譯")
pie(data,labels,main ="學生的比例", col=heat.colors(length(data)))