1

I have a dataset currently sorted by date and time. I have a column called 'day' and is just the day of the month, in numerical form i.e. 1-31 I have a 14 days stretch that I want to plot, however it starts from 30th of one month, to the 13th of the next. When I try to plot it, it orders 1-13,30,31.

How can I plot the x axis as it is found within the dataframe?

Thanks.

Coffeee
  • 143
  • 1
  • 2
  • 13
  • Please make your situation reproducible, i.e. provide us with the data and the code needed to mimic your situation. See http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example for more tips on how to do this. – Paul Hiemstra Mar 12 '13 at 18:30
  • Check out this blog post: http://trinkerrstuff.wordpress.com/2012/10/15/how-do-i-re-arrange-ordering-a-plot/ – Tyler Rinker Mar 12 '13 at 18:35

1 Answers1

1

Make sample data with columns day and value.

df<-data.frame(day=c(30,31,1,2,3,4,5,6,7,8),value=rnorm(10))

If column day contains just day values as numbers you can convert them to factor and set levels as original order of values.

ggplot(df,aes(factor(day,levels=df$day),value,group=1))+geom_line()
Didzis Elferts
  • 95,661
  • 14
  • 264
  • 201