On Fri, 2007-02-16 at 14:32 +0000, Sérgio Nunes wrote:
> Hi again,
>
> I'm still trying to read my data but I'm having some difficulties
> converting it to dates.
> My data file has lines and in each line a single date exists in the
> format >2007/02/16< (without the >,<). I've tried the following:
>
> > d <- readLines("file.dat")
> > d
> [1] "2006/08/09" "2004/02/11" "2004/06/09" ...
> [2] ...
>
> > d2 <- as.Date(d, format="%Y/%m/$d")
You have a typo above. '$d' should be "%d":
d2 <- as.Date(d, format = "%Y/%m/%d")
> str(d2)
Class 'Date' num [1:3] 13369 12459 12578
HTH,
Marc Schwartz
<snip>
______________________________________________
[email protected] 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.