-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
  • 24,556
  • 5
  • 34
  • 51
kevin
  • 311
  • 2
  • 10

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
  • 789,025
  • 32
  • 460
  • 575