I have the following dataset:
a<-data.frame(time=c("before","after","before","after"),
company=c(1,1,2,2),
value=c(3.751522,4.776224,3.838707,2.644144 ))
I want to create a plot, where barplots depicting on the left Company 1 "before" and "after" values. At the same time Company 2 "before" and "after" values on the right side of the plot. So, on y axis should be the variable "value", but on the x axis should be "before" and "after" 2 times, because Company 1 on the left and company 2 on the right side.
I tried the following code :
ggplot(data=a, aes(time,company,group=interaction(company, time)))+
geom_col(aes(y=value))
Unfortunately it only yields sum of variable "value" for the time periods "before" and "after" ignoring the company names.
Doing it as two separate plots and then using grid.arrange() will take more space than simply plotting it initially in the one graph.


