I can't get R to not put my binned data in alphabetical order
<p>I'm trying to make a bar graph for publication, and I'm trying to show the change in operation types performed at our hospital before a curriculum implementation and after, "BR" and "AR" respectively. The types of operation are "Open", "Laparoscopic", and "Robotic". I would like the "BR" values to come before the "AR" values on my bar graph, but I can't seem to figure out how to get R to read them in that order (I'm fairly new to R and coding :( ). my data frame is named df</p>

<pre><code>           bin type cases_per_month
1         Open   BR           18.35
2         Open   AR           15.50
3 Laparoscopic   BR            4.25
4 Laparoscopic   AR            1.95
5      Robotic   BR            0.10
6      Robotic   AR            1.15

ggplot(data=df, aes(x=bin, y=cases_per_month)) + geom_bar(stat="identity")

data &lt;- tapply(df$cases_per_month, list(df$type, df$bin), sum)
barplot(data, beside=T, col=c("black", "grey"),
    main="Average Cases per Month,BR and AR: Ventral", 
    xlab="Case Type", ylab="Average Cases per Month")
legend(locator(1), rownames(data), fill=c("black","grey"))
</code></pre>

<p>because R reads "BR" and "AR" as atomic vectors, most of the commands I've tried won't let me reorder it how I want to</p>

<p><img src="https://i.stack.imgur.com/I5Gih.jpg" alt="enter image description here"></p>

<p>This is what I'm getting now. I also want my y axis to go up to 20, but I just need to google that, I'm sure</p>