I have a panel data set that has a column with date entries, though they are in class "character", with some as mm/dd/yyyy, and others with dd-mm-yyy. I want to format these into a Date vector, so that I can subset the data according to a cutoff date. However, as.date
does not work, since the formatting of the entries varies.
df$OPdate <- as.Date(OPdate, format = "%Y-%M-%D")
dfnew = subset(df,OPdate < "2021/3/29")
df_age14 = subset(dfnew, age > 13)
list14 = unique(df_age14$postID)
finaldf = subset(df, postID %in% list14)
This is the code I am trying to run once the dates are formatted correctly. Any suggestions? Thanks in advance