I'm using the code below to try to change the date format of a file that I imported from a CSV file. It works fine and returns dates like "2013-09-21". However, I want it to return 9-21-2013. I tried changing the format to Y/d/m, but it returns all NAs. How can I fix this?
web <- read.csv("Web.csv", header = TRUE)
as.Date(web$CLAIM.DATE, format = "%m/%d/%Y")
Also, on a related note, how can I replace the column in the web data set with the values from as.date (when I get it correct)? Thanks!!
format
argument is tellingas.Date()
the current format so it knows how to correctly read the date in. It is not telling it the format you want displayed. – Gregor ThomasNA
with Y/d/m. – Gregor Thomas