設定年月日
計算每個weekdays頻率
bdays <- seq(from=db_SWE, to=dd_SWE, by="year")
day <- function(x){
y <- sum(weekdays(bdays) %in% x)
return(y)
}
day("星期日");day("星期一");day("星期二");day("星期三");day("星期四");day("星期五");day("星期六")## [1] 14
## [1] 15
## [1] 14
## [1] 15
## [1] 14
## [1] 15
## [1] 14
建立data.frame
繪圖
ggplot(dta, aes(day, times)) +
geom_bar(width=0.5,
stat="identity",
fill="blue",
alpha=0.3)+
labs(title = '',
x = "Weekdays",
y = "Times")+
theme_classic() +
geom_text(aes(label = times),size = 6)+
theme(axis.text.x = element_text(size = 15),
axis.text.y = element_text(size = 15))