I need to change the order of the bars in my barplot. The default is alphabetical which I do not want. I need the order to be "Elementary School", "Middle School", "High School".
colors <- c("cornflowerblue","mediumpurple1","coral2", "azure4")
colorsleg <-c("cornflowerblue","mediumpurple1","coral2", "azure4")
mytable <- table(century$race, century$type)
mytable2 <- prop.table(mytable, 2) #changes counts to percentages#
M <- c(
"Elementary
School",
"High
School",
"Middle
School")
par(mar=c(5, 6, 4.1, 2.1)) #THIS CHANGES THE GRAPHS MARGINS TO MAKE
#ROOM FOR LONG Y LABELS. default margin sizes are mar=c(5.1, 4.1, 4.1, 2.1)
#
barplot(mytable2,
col=colors,
border = NA,
ylim = range(0,3),
xlim = range(0,1),
# #THIS GETS RID OF Y AXIS LINE#
family="Arial",
horiz = T, names.arg= M,
las=1)`
`
I need the order to Elementary School, Middle School, High School.