I am using ggplot to produce a bar chart stacked by a factor. And I use the following code
ggplot(X) +
geom_bar(aes(X$Decade, fill=factor(X$Motivation)),
position='fill') +
theme(legend.position = "bottom")+
theme(axis.title.x = element_text(size = 20),
axis.title.y = element_text(size = 20))+
theme(text = element_text(size=20))+
theme(legend.text = element_text(size = 16),legend.title = element_blank())+
xlab("Decade")+
ylab("Percentage")+
scale_y_continuous(labels=percent)
However the program gives the following warning,
Warning message: position_fill requires non-overlapping x intervals
The resulted figure is the below
It seems that the warning liers in the decade 1940. When the observations of 1940 are this
I don't know what's the problem here, since other observations look like those of 1940 and when I removed 1940 observations, no warnings any more.