Converting 20110101 to 1

For all the things you want to do, it would be easier if you work with dates instead of integers, try to do something like this.

library(dplyr)
library(lubridate)
library(ggplot2)

sample_data <- data.frame(date = c(20110101L, 20111231L, 20120105L),
                          value = runif(3, 0, 20))
# Converting integers to dates
sample_data <- sample_data %>%
    mutate(date = ymd(date))
# Using dates with ggplot
sample_data %>% 
    ggplot(aes(x = date, y = value)) +
    geom_col() +
    scale_x_date(date_breaks = '1 month', date_labels = '%Y-%m') +
    theme_bw() +
    theme(axis.text.x = element_text(angle=30, hjust=1, vjust = 1))

Created on 2019-02-08 by the reprex package (v0.2.1)

We could give you better help if you provide a REPRoducible EXample (reprex) If you've never heard of a reprex before, you might want to start by reading this FAQ:

1 Like