I want to change the time format, which I have as column ("Date") in my data frame ("data"). It is imported from a csv as -Q1 1990- and I would like to have it as -1990Q1-, but my function is not perfect. I tried:
for (i in 1:length(data$Date)){
data$Date[i] <- paste(substr(data$Date[i], 4,8),substr(data$Date[i], 1,2),
sep="")
}
The result is a column in which each row has a NA and I do not know why. Can someone help? I found already the thread Extracting the last n characters from a string in R. In that threat they only mentioned the problem, but did not solve it in an understandable way for me.
Thanks in advance