Hope this will be easy to understand. This is basically the same example as here .

Using
ggplot(mtcars, aes(factor(cyl), fill = factor(vs))) +
geom_bar(position = position_dodge(preserve = "single"))
But I get Error in position_dodge(preserve = "single") :
unused argument (preserve = "single"). ggplot2 version 2.2.1
So how to change the code
ggplot(mtcars, aes(factor(cyl), fill = factor(vs))) +
geom_bar(position = "dodge")
In order not to get this super wide bar, as shown below, but the same as there.

source
share