a.Date() function creates "NA NA NA NA NA NA"

A date object is always going to consist of three componenets, year, month and day. The usual way to collapse dates into months is to use the "date floor" (i.e. 2017-07-01)


floor_date(as.Date(c("2017-07-29", "2017-07-01")), unit = "month")
#> [1] "2017-07-01" "2017-07-01"

Created on 2020-08-14 by the reprex package (v0.3.0)

After you have made all your required calculations you can change the date format at the end as you have done in your example, but just for presentation purposes.

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

1 Like