I wrote the following script in R software in order to converting date format in a prospective cohort data. But, I get an odd error. Could everyone help me? Any idea?
Code:
for(col in colnames(outcome)){
if(startsWith(col, "eventdate_")){
outcome[, col] <- as.Date(outcome[, col],"%Y-%m-%d")
}
}
Error: Error in as.Date.default(outcome[, col], format = "%Y-%m-%d") : do not know how to convert 'outcome[, col]' to class “Date”