I have this data frame with the value I want to take to the graph which is the_bin and the value where I want them to be arranged which is the_bin_num but. And I get something:
You can see that they are not arranged at all I would be happy for ideas
ggplot(data = data_by_time2,aes(x=the_bin,y=avg,fill =avg))+geom_bar(stat = "identity",position = "dodge")+
labs(title = "Average Profit According To The Running Time Of The Movie",x="Run Time",y="Mean Trim Profit",color="Mean Trim Profit",fill="Mean Trim")+
facet_grid(.~genres)+theme(axis.text.x = element_text(angle = 90,vjust = 0.5 ,hjust = 1))
I had a similar problem with a very simple solution: forcats::fct_inorder()
The function fct_inorder() uses the current table order to order the resulting factor.
data_by_time2 %>%
arrange(the_bin) %>%
ggplot(data = data_by_time2,aes(x=forcats::fct_inorder(the_bin),y=avg,fill =avg))