Skip to content
Prev 31009 / 398506 Next

Plotting Factors -- Sorting x-axis

case?
How about this:

# Create vector as you have with chars
# Note the factor level values
[1] 1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17 18
[19] 19 20
20 Levels: 1 10 11 12 13 14 15 16 17 18 19 2 20 3 4 ... 9

# Now sort factor levels by numeric value
# Note the factor level values
[1] 1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17 18
[19] 19 20
20 Levels: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ... 20

Now plot(x).

Hope that helps.

Marc Schwartz