I want to convert Date into factor for sequential analysis.

I tried the following code:
start_month <- '2019-01-01'
elapsed_month <- function(end_date, start_date) {
ed <- as.POSIXlt(end_date)
sd <- as.POSIXlt(start_date)
12 * (ed$year - sd$year) + (ed$mon - sd$mon)
}
trans_sequence$eventID <- elapsed_month(trans_sequence$repdate, 
start_month)
But i got the following output:

Instead I wish following output:

Thank You for your Help !!
 
     
    