Sorry if this is very basic, but I am quite new to this. I am creating boxplots for some survey data in R using boxplot(). I notice it automatically arranges the x groups in alphabetical order, which doesn't suit my needs. In my data frame I changed the names to have an 'a' or 'b' at the beginning. This puts them in the order I want but then the label isn't neat. I would like to be able to override the x labels from the data frame with my own labels OR decide the order of the values along the x axis. Basically I just want 'Riparian' to come first, then 'Floodplain'. I have a number of other boxplots to do as well, some will have more than 2 values on the x axis.
This is the data and the code without trying to override the labels
Script
boxplot(tot_sp ~ hab, data = mydata, xlab= "Habitat Type", ylab = "Total # Species")
title("Bird Search: Total Species")
Some other scripts I have tried, none have worked.
boxplot(tot_sp ~ hab, data = mydata, axis(1, at=seq(1, 2), labels = labels.name),
xlab= "Habitat Type", ylab = "Total # Species")
boxplot(tot_sp ~ hab, data = mydata, 'labels',{'Riparian', 'Floodplain'}, at=NULL,
xlab= "Habitat Type", ylab = "Total # Species")
boxplot(tot_sp ~ hab, data = mydata, xtix = {'Riparian', 'Floodplain'}, xtixloc = [1, 2],
xlab= "Habitat Type", ylab = "Total # Species")
Thanks very much for your help!