0

This is a really weird problem...

I have my data here:

enter image description here

with my code:

ggplot(data=data_by_day_all, aes(x=days, y=values, group=1)) +
  geom_line()+
  geom_point()+
  theme(axis.text.x = element_text(angle = 90))

But the x axis labels is coming out like this:

enter image description here

Can anyone solve this or give me some advice? Thanks!

Amoroso
  • 945
  • 2
  • 10
  • 21
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Pictures of data are not helpful. Is the "days" column a character vector or a factor? – MrFlick Feb 18 '19 at 17:20
  • @MrFlick tried 'days' column both as a factor and character column – Amoroso Feb 18 '19 at 17:22
  • No, how was it read into R? Once you create a factor, it remembers it levels. You need to specify the order then. It it's a character column first, you can keep the data in the order it appears, but if you read it in as a factor, then you need to do change things up. Again, it would be easier just to show you with a proper reproducible example. – MrFlick Feb 18 '19 at 17:24
  • Thanks alot @MrFlick, solved it! Did not know that ggplot does a reordering. Was stuck on this issue for so long. Thank you!!! – Amoroso Feb 18 '19 at 17:25

0 Answers0