R: Sorting a data frame by an alphanumeric
问题 I have a data frame which stores a count value for each model. Model name is an alphanumeric. Then I generate a bar plot using ggplot2 having the models in the x axis and the count in the y axis. I want to order my x axis. The x axis appears as follows in the data frame and in the x axis in the plot. I want to sort it properly for example, M_1, M_2, M_3, M_10, M_11, M_20 etc Model Count M_1 73 M_10 71 M_100 65 M_11 65 M_110 64 M_111 71 M_13 70 M_130 73 M_2 72 M_20 69 M_200 63 M_21 72 M_210 72