Skip to content

Ordering bars in barplots

2 messages · Scott Norton, Brian Ripley

#
by() will sort on the levels of `class', so I think what you need to do is 
ensure that `class' has its levels sorted numerically.  Try

df$class <- factor(as.numeric(as.character(df$class)))

to do that.  Then to sort the df by numerical class you could use

df <- df[sort.list(unclass(df$class)), ]

It might be easier just to make class a number for some purposes at
least (just omit the factor() above).
On Thu, 15 Jan 2004, Scott Norton wrote: