I wish to import my csv file into a data frame but the date in my csv file is in a non-standard format.
The date in the first column is in the following format:
One of the arguments in my read.csv2 functions is to specify the classes and when I specify this column as a date I receive the following error upon execution:
Error in charToDate(x) :
character string is not in a standard unambiguous format
When you convert character to date, you need specify format if it is not standard. The error you got is the result of
as.Date("08.09.2016"). But if you do
as.Date("08.09.2016", format = "%m.%d.%Y"), it is fine.
I am not sure whether it is possible to pass format to
read.csv2 for correct date formatting (maybe not). I would simply read in this date column as factor, then do
as.Date(as.character(), format = "%m.%d.%Y") on this column myself.
Generally we use the following format "dd/mm/yy" how can I reorganise the date to that format?
format(, format = "%d/%m/%y").
A complete example:
format(as.Date("08.09.2016", format = "%m.%d.%Y"), format = "%d/%m/%y") #  "09/08/16"