I am trying to create a plot in R, its very simple however this has been bugging me for days and I can not get it to work. When I make the plot R orders the y axis by alphabetical order, how do you specify the order you want. Using the example below:
x = c("High ind.", "High sp.", "Mid ind.", "Mid sp.", "Low ind.", "Low sp.")
y = c(4.6, 2.3, 5.5, 2.2, 12.6, 3)
sd = c(3.2, 1.2, 4.4, 1.5, 5.9, 1.5)
qplot(x,y, xlab="Water level",
ylab="mean number of ind. and sp. with standard deviations") +
geom_errorbar(aes(x=x, ymin=y-sd, ymax=y+sd, width=0.2), color="blue")
I would like the order on the y axis like this: High, Mid, Low. However R automatically puts it in alphabetical order. I have tried many ways to fix this however they are all aimed at large more complex datasets, and do not work with such a simple set of data. There must be a simple way to fix this..