Statistic <- c(68,85,74,88,63,78,90,80,58,63)

Math <- c(85,91,74,100,82,84,71,100,51,70)

plot(Statistic,Math,
     pch=15,
     col="#CA8EFF",
     xlab="Statistic",
     ylab="Math",
     main="10人的統計成績與數學成績")

hist(Math,
     col= "#8F00FF",
     main ="數學成績或統計成績",
     xlab ="數學成績",
     ylab ="統計成績")

library(ggplot2)

data <- data.frame(
  name=c("娛樂休閒","知識閱讀","體育競技","科學創新","公益活動") ,  
  value=c(185,82,36,28,25)
  )

ggplot(data, aes(x=name, y=value)) + 
  geom_bar(stat = "identity", width=0.2, fill="#FFD9Ec" )

data2<- c(185,82,36,28,25)
labels <- c("娛樂休閒","知識閱讀","體育競技","科學創新","公益活動")

pie(data2,labels,main ="大學生最喜歡參加的社團的次數分配表", col=heat.colors(length(data)))

## 
##   The decimal point is 1 digit(s) to the right of the |
## 
##   4 | 9
##   5 | 139
##   6 | 1
##   7 | 9
##   8 | 59
##   9 | 1
mean(Japan)#平均數
## [1] 68.51444
median(Japan)#中位數
## [1] 61
max(Japan)#眾數
## [1] 91
sd(Japan)#標準差
## [1] 17.21255
var(Japan)#變異數
## [1] 296.2719
Q1 <- quantile(Japan, 1 / 4)
Q3 <- quantile(Japan, 3 / 4)
Q1#Q1第一四分位數
## 25% 
##  53
Q3#Q3第三四分位數
##   75% 
## 84.63
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)

df = data.frame(
  name=c("north","south","south-east","north-west","south-west"),
  val=sample(seq(7,15), 5)
)

ggplot(df, aes(x=name, y=val, fill=name)) +
  geom_bar(stat="identity", alpha=.6, width=.4) +
  scale_fill_grey(start=0, end=0.9) +  # start and end define the range of grays
  theme_bw()

library(ggplot2)
library(hrbrthemes)
## Warning: 套件 'hrbrthemes' 是用 R 版本 4.4.3 來建造的
data3 <- data.frame(Statistic,Math)
ggplot(data3, aes(x=Statistic, y=Math)) + 
    geom_point(
        color="orange",
        fill="#69b3a2",
        shape=21,
        alpha=0.5,
        size=6,
        stroke = 2
        )