Here is one solution.
DF = data.frame(Date=c("2012-02","2012-03","2012-04"),
Value=c(18,25,31))
library(lubridate)
#>
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#>
#> date, intersect, setdiff, union
DF$Date <- ym(DF$Date)
DF
#> Date Value
#> 1 2012-02-01 18
#> 2 2012-03-01 25
#> 3 2012-04-01 31
Created on 2022-07-21 by the reprex package (v2.0.1)