As @EconomiCurtis said you should provide a reprex. The reprex in CRAN right now has some issues so my will find it easier to use the version in github ( which will eventually end up in CRAN).
Until CRAN catches up with the latest version install reprex with
devtools::install_github("tidyverse/reprex")
Also you reprex should be as simple as possible and illustrate the particular issue you are running into rather than the overall code that that is running into the issue.
In any case the problem you are probably running into is that as.Date creates a Date object and a Date object contains the number of days from 1970-01-01. Since something like "2017-05" doesn't specify a particular day there is no way it can compute the number of days form 1970-01-01.
If you want to use as.Date as a year + month just make a convention that year-month always specify the first day of the month.
You could make a helper function to make it more convenient to implement this year-date conventions, like this:
makeMonthDate <-function(year_month) {
usedate <- paste(year_month, "-01", sep="")
as.Date(usedate, "%Y-%m-%d")
}
makeMonthDate("2017-4")
#> [1] "2017-04-01"
Created on 2018-03-05 by the reprex package (v0.2.0).