Skip to content
Prev 154551 / 398500 Next

R graphical question

The answer to your question gets a  bit into the philosophy of programming and data storage.  Is the order of levels of a factor a property of the plot? Or a property of the factor/data itself?

Some programs see this as a property of the plot, so you specify the order at the time you create the plot (and have to respecify it every time).

R/S sees this as a property of the data itself, so you should set the order when creating your factor (or change it on the factor) before plotting, then every time you plot (or other things) with this data, it automatically does the correct thing.  One way to change the order in your factor is:
Or you can make a copy with a different name so that the original stays unchanged (just plot using the new copy).

There are also functions with names like reorder and relevel in some packages that may (or may not) be easier to use to reorder the levels of the factor.

Now, just plot like you did before and see what order the categories are plotted in.

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
(801) 408-8111