Y-axis output is not order I am currently attempting to output some data based on user agent strings. The strings are too messy to place into a plot similar to the one shown below, so I plotted their index instead. Why is my plot outputting out of order? I would like to have my $y$-axis be in ascending order. 

For context, I am plotting 6 plots with a for loop and none of them are producing the y-axis in order.

Edit: I added 'uas_id' dplyr code with solution.



gbuas_large&lt;-gbuas_large%&gt;%
              mutate(uas_id = sort(strtoi(rownames(gbuas_large))))%&gt;%
              select(user_agent_string,uas_id,everything())

col&lt;-names(gbuas_focus[,5:10])

for(i in col) {
  print(i)
  ua_p&lt;-ggplot(gbuas_focus
              )+
    geom_point(aes_string(
                x=i,
                y='uas_id'),
                color="#70a6ff",
                size=3
               )+
    labs(x='Variable of Score',
         y='User Agent Strings',
         title="Understanding Misclassifying Variables"
        )+
    facet_wrap(~classification)
    print(ua_p)
}
It is in order, but not in the order that you want. 

It is currently treating the indices as a string. 

To get your desired index as numerics, here are some codes that hopefully can help you.

&gt; c = c("1", "2", "13")
&gt; c = sort(c)
&gt; c
[1] "1"  "13" "2" 
&gt; c = strtoi(c)
&gt; c
[1]  1 13  2
&gt; sort(c)
[1]  1  2 13