I am new to R and I would like to create a vector between 2 dates a
Here is my code
start.plot <- c("2011-01-01", "2012-12-31")
plot1 <- substr(start.plot[1],1,7)
plot2 <- substr(start.plot[2],1,7)
Month_test <- as.character(seq(as.Date(start.plot[1]), as.Date(start.plot[2]), by="months"))
and here is the result of this code
[1] "2011-01-01" "2011-02-01" "2011-03-01" "2011-04-01" "2011-05-01" "2011-06-01"
[7] "2011-07-01" "2011-08-01" "2011-09-01" "2011-10-01" "2011-11-01" "2011-12-01"
I just needed the YYYY-MM format for this date as a character like this
[1] "2011-01" "2011-02" "2011-03" "2011-04" "2011-05" "2011-061"
[7] "2011-07" "2011-08" "2011-09" "2011-10" "2011-11" "2011-12"
What's the best way to code this in R? Thanks