Skip to content
Prev 389799 / 398506 Next

Date

My speculation is that Microsoft Excel recognized that as a date and 
saved it in the "mm/dd/YYYY" format you saw when reading it into R with 
dat=read.csv("myfile.csv").


	  "str" told you the format.  You can convert that from character to 
Date using as.Date(dat$mydate, '%m/%d/%Y'), as documented in 
help('as.Date').


NOTE: The error message, "character string is not in a standard 
unambiguous format" is almost appropriate:  In this case, it's clear 
that "09/16/2019" refers to month 09, day 16, and year 2019.  However, 
if it were "09/06/2019", we would not know if it were September 6 or 9 
June of 2019.  If it were  "09/06/08", we would have the added 
possibility with the year first, followed by month and day:  June 8, 
2009.  This ambiguity is resolved most forcefully by ISO 8601.


	  Hope this helps.
	  Spencer Graves
On 11/4/21 5:30 PM, PIKAL Petr wrote: