[R] How to make a time series object from a data frame containing dates.

Gabor Grothendieck ggrothendieck at gmail.com
Wed Apr 22 20:10:52 CEST 2009


In particular,

library(zoo)
z <- zoo(x$alloc_gb, x$month)
plot(z)

See the three zoo vignettes
vignette(package = zoo) # to list them
vignette("zoo") # to show first one

and the help files

library(help = zoo)
?zoo


On Wed, Apr 22, 2009 at 1:07 PM, stephen sefick <ssefick at gmail.com> wrote:
> look at the zoo package where there are quite a few functions to help with this.
>
> Stephen Sefick
>
> On Wed, Apr 22, 2009 at 11:09 AM, Lane, Jim <jim.lane at rbc.com> wrote:
>> Hi, All
>>
>> I have a data frame like this.
>>
>>> names(x)
>> [1] "month"    "alloc_gb"
>>
>> One of the columns contains the dates I want to use:
>>
>>> data.class(x$month)
>> [1] "yearmon"
>>
>> I would like to make a time series object out of this. However the ts
>> function seems to require me to spell out the starting date. Is there a
>> way to tell ts to use the date column I already have? A naive version of
>> the syntax I was expecting to find would have been something like:
>>
>> maketimeseries(values=x$alloc_gb,dates=x$month)
>>
>> Or am I seriously missing something somewhere?
>>
>> Jim Lane
>> Capacity Planner
>> RBC Financial Group
>> 315 Front St W
>> 6th Floor - H14
>> Toronto, Ontario CANADA
>> M5V 3A4
>> 416-348-6024
>>
>> Display of superior knowledge is as great a vulgarity
>> as display of superior wealth - greater indeed, inasmuch
>> as knowledge should tend more definitely than wealth
>> towards discretion and good manners.
>>
>> - H. W. Fowler, Modern English Usage
>>
>>
>> _______________________________________________________________________
>>
>> This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations.
>> Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized.
>> If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.
>>
>> Ce courrier électronique est confidentiel et protégé. L'expéditeur ne renonce pas aux droits et obligations qui s'y rapportent.
>> Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) désigné(s) est interdite.
>> Si vous recevez ce courrier électronique par erreur, veuillez m'en aviser immédiatement, par retour de courrier électronique ou par un autre moyen.
>>
>>        [[alternative HTML version deleted]]
>>
>>
>> ______________________________________________
>> R-help at 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.
>>
>>
>
>
>
> --
> Stephen Sefick
>
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods.  We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
>                                                                -K. Mullis
>
> ______________________________________________
> R-help at 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.
>




More information about the R-help mailing list