I have looked at a few other posts where this problem has occurred but can’t seem to apply any of the suggestions to my case. Whenever I try reorder with the mean it does not work but works when reorder is used with the median. Here is an example where I tried reorder with mean:
values <- c(1,2,3,4,5,6,2,3,4,5,6,3,4,5,6,7,8,9)
group <- c('t1','t1','t1','t1','t1','t1','t2','t2','t2','t2','t2','t2','t3','t3','t3','t3','t3','t3')
df<- data.frame(values,group)
boxplot(values~group, data=df) ## two groups with same median
mean_values <- aggregate(df$values, by = list(df$group), FUN = mean)
medianvalues <- aggregate(df$values, by = list(df$group), FUN = median)
mean_values # groups have different means
medianvalues # two groups have same median
new_order1 <- with(df, reorder(group, values, mean, na.rm=T)) # want lowest mean first
boxplot(values~new_order1, data=df) # but nothing changes?