My R code:
1. df <- data.frame(table(mast$State))
2. df
3. df <- df[order(df$Freq,decreasing = FALSE),]
4. df
5. df1 <- ggplot(df,aes(x=Var1,y=Freq))+geom_bar(stat="identity")+coord_flip()
6. df1
Line 1 - created new dataframe with freq table of variable 'State' in original dataframe mast - worked fine
Line 2 - executed df to view whether the output is correct - worked fine
Line 3 - arranged the frequency table in increasing order - worked fine
Line 4 - executed df again to check whether data is arranged in an order - worked fine
Line 5 - wanted horizontal bar for dataframe df with varaible 'State'arranged in an order - Not working
why the horizontal bars are not getting arranged in an order though in line 4 freq table was arranged in an order? My final output is: enter image description here