-1

I have a data frame in the format of:

["201301",1111],["201302",1111],["201702",2222],["201603",3333].

When I try to plot it using ggplot, there is a huge gap between years. I think the problem is caused by x value is consider as number. enter image description here

Is it possible to fix the issue without using other libries?

Thanks!

markus
  • 25,843
  • 5
  • 39
  • 58
kevin
  • 309
  • 2
  • 12

1 Answers1

2

One option is to paste a day and then use as.Date

as.Date(paste0("201301", "01"), "%Y%m%d")
#[1] "2013-01-01"
akrun
  • 874,273
  • 37
  • 540
  • 662