One question I would have about your commands is that I would have thought
that the second line of output ([2].....) would have started with at least
[4] if you were reading multiple lines.  This example seems to work fine:
(now that I looked at your code you had $d instead of %d)

> x <- readLines(textConnection("2006/04/08
+ 2005/1/2
+ 2005/1/2
+ 2005/1/2
+ 2005/1/2
+ 2005/1/2
+ 2005/1/2
+ 2005/1/2
+ 2005/1/2
+ 2007/12/21"))
> x
 [1] "2006/04/08" "2005/1/2"   "2005/1/2"   "2005/1/2"   "2005/1/2"
"2005/1/2"   "2005/1/2"
 [8] "2005/1/2"   "2005/1/2"   "2007/12/21"
> as.Date(x, format="%Y/%m/%d")
 [1] "2006-04-08" "2005-01-02" "2005-01-02" "2005-01-02" "2005-01-02"
"2005-01-02" "2005-01-02"
 [8] "2005-01-02" "2005-01-02" "2007-12-21"
>


On 2/16/07, Sérgio Nunes <snunes@gmail.com> 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")
> > d2
> [1] NA NA NA ...
> ...
>
> I'm surely doing something wrong.
> Any advice would be welcomed.
>
> Thanks!
> Sérgio Nunes
>
> On 2/15/07, Sérgio Nunes <snunes@gmail.com> wrote:
> > Hi,
> >
> > I have several files with data in this format:
> >
> > 20070102
> > 20070102
> > 20070106
> > 20070201
> > ...
> >
> > The data is sorted and each line represents a date (YYYYMMDD). I would
> > like to analyze this data using R. For instance, I would like to have
> > a histogram by year, month or day.
> >
> > I've already made a simple Perl script that aggregates this data but I
> > believe that R can be much more powerful and easy on this kind of
> > work.
> >
> > Any suggestions on where to start?
> >
> > Thanks in advance,
> > Sérgio Nunes
> >
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

	[[alternative HTML version deleted]]

