[R] Converting data frame to zoo
Gabor Grothendieck
ggrothendieck at gmail.com
Fri Jul 7 20:09:25 CEST 2006
read.zoo supports all the arguments that read.table supports including
header=. From the read.zoo help file:
...: further arguments passed to 'read.table'.
Regards.
On 7/7/06, Horace Tso <Horace.Tso at pgn.com> wrote:
> Thanks Gabor. I figured out what went wrong. The culprit turns out to be
> the headers in my data. read.zoo doesn't recognize column headers and
> complains
>
> Error in read.zoo("C:\\.......\\table.csv", :
> index contains NAs
>
> Or is there an option as in read.table(x, header=...) ?
>
> After the header line is removed it works fine.
>
> H.
>
>
>
> >>> "Gabor Grothendieck" <ggrothendieck at gmail.com> 7/7/2006 10:22 AM
> >>>
> Check out read.zoo in the zoo package.
>
> On 7/7/06, Horace Tso <Horace.Tso at pgn.com> wrote:
> > Dear list,
> >
> > I know this is really basic question but I just couldn't get
> anything
> > to work. (I did a R site search with keywords "zoo" and "data frame"
> but
> > the server timed out on me.)
> >
> > I have a time series which has the following (typical) format,
> >
> > DATE Open High Low Close
> > Volume
> > 01-JAN-2006 5.25 5.25 5.25 5.25
> > 256
> > ....
> >
> > I read the data in from a csv file with read.csv() and it defaulted
> to
> > a data frame which I thought is fine. Now I want to convert it to zoo
> so
> > I did
> >
> > x <- zoo(my.df)
> >
> > which works just fine. But the Date column has been turned into a
> > factor. Is there a way to make it into a Date. I've tried,
> >
> > x$Date <- as.Date(x$Date)
> >
> > but R complains that
> >
> > Error in fromchar(x) : character string is not in a standard
> > unambiguous format
> >
> > Thanks in advance.
> >
> > Horace W. Tso
> >
> >
> >
> >
> >
> >
> > ______________________________________________
> > R-help at 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
> >
> > ______________________________________________
> > R-help at 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
> >
>
More information about the R-help
mailing list