On Fri, 3 Feb 2012, Ana wrote:
Hi
I have many excel files were the Date field was not declared as date,
so the dates look like this: 1/2/1978
I know that the format is day/month/year
How can I make R change this to Date format?
If I use strftime, I get wrong dates:
So use as.Date to convert to the Date class.
as.Date(dataset,"%d/%m/%Y")
[1] "1978-02-01"
dataset=c("1/2/1978")
strftime(dataset,"%d/%m/%Y")
"19/02/0001"
On some unstated OS (how year 1 is represented is OS-dependent).
The format in strftime applies to output: the default one is used for
input.
--
Brian D. Ripley, rip...@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.