Here I have a chr column data$month which initially was like this "1980m10". I'm trying to convert it into a date format so I can plot line graph for stock returns. however when I try
as.Date(data$month, "%Ym%m")
it returns me only NA values.
I have tried to convert the column into more clear format
data$year = substr(data$month,1,4)
data$mon = substr(data$month,6,8)
library(stringr)
data$month = paste(data$year,'-',data$mon)
as.Date(data$month, "%y - %m")
However still it returns me only NA values. Idk how to solve this problem. I have tried without format: but it says the character string is not in a standard unambiguous format