Q:

Monthly Time series data in ggplot2

I want to plot monthly time series with data below and I am getting the Error: 
Invalid input: date_trans works with objects of class Date only* 

Any help will be much appreciated.
below is my code: 
theme_set(theme_bw())
rdata1_m <- rdata1[1:36, ]
lbls <-paste0(month.abb[month(rdata1_m$date)], " ",lubridate::year(rdata1_m$date))
brks <- rdata1_m$date 
ggplot(rdata1_m, aes(x=date)) +geom_line(aes(y=GoldPrice)) +
scale_x_date(labels = lbls,breaks = brks) +
theme(axis.text.x = element_text(angle = 90, vjust=0.5),
panel.grid.minor = element_blank())

and my data is: enter image description here 

A:

Using the data shown reproducibly in the Note at the end convert to a zoo time series object with yearmon class index.  The yearmon class represents monthly data, i.e. dates containing a year and month but no day.  Finally use autoplot.zoo together with scale_x_yearmon.  See ?scale_x_yearmon for arguments that can be used to customize it if you don't like the defaults.
library(ggplot2)
library(zoo)

z <- read.zoo(rdata, FUN = as.yearmon)
autoplot(z) + scale_x_yearmon(format = "'%y/%m")

Another possibility is to convert to a ts object and then use autoplot.ts from ggfortify.  Using z and the library statements from above we write
library(ggfortify)

autoplot(as.ts(z))

Note
Lines <- "date GoldPrice 
2004-11-01 439.38 
2004-12-01 442.08 
2005-01-01 424.03 
2005-02-01 423.35 
2005-03-01 433.85 
2005-04-01 429.23 
2005-05-01 421.87 
2005-06-01 430.66 
2005-07-01 424.48 
2005-08-01 437.93 
2005-09-01 456.05 
2005-10-01 469.9 
2005-11-01 476.67 
2005-12-01 510.1 
2006-01-01 549.86 
2006-02-01 555 
2006-03-01 557.09 
2006-04-01 610.65 
2006-05-01 675.39 
2006-06-01 596.15 
2006-07-01 633.71 
2006-08-01 632.59 
2006-09-01 598.19 
2006-10-01 585.78 
2006-11-01 627.83 
2006-12-01 629.79"

rdata <- read.table(text = Lines, header = TRUE)

