ある疾患の届出数の推移(2010~2021年)を患者の年齢階層別に100%積み上げグラフで作成したいと思っています。
以下のコードでグラフを作成したのですが、X軸の年が2010から4年間隔で2022年まで表示されてしまいます(2010、2013、・・・2022)。この2022を消すか、最後のみ2021を表示させるためにはどうしたらよいでしょうか。
よろしくお願いします。
Fig3dat<-(table(datnew10_21_activeTB$age_group5, datnew10_21_activeTB$reg_y))
Fig3datmelt<-melt(Fig3dat, id.vars = "Year", variable.name = "Age_group", value.name = "Case")
colnames(Fig3datmelt)<-c( "Age_group", "Year","Case")
ce<-ddply(Fig3datmelt, "Year", transform, percent_case=Case/sum(Case)*100)
Fig3<-ggplot(ce, aes(x=Year, y=percent_case, fill=Age_group))+geom_bar(stat="identity")+
theme_classic()
Fig3<-Fig3+ggtitle("Figure 3. Newly notified cases by age groups, 2010-2021")+xlab("Year")+ ylab("Number of cases")
+scale_fill_discrete(name="Age groups")
xlim(c(2010, 2021))
を追加すればよいのではないでしょうか。