[R] Some basic time series questions
Paul Gilbert
pgilbert902 at gmail.com
Thu Nov 17 22:06:34 CET 2016
On 11/17/2016 06:00 AM, r-help-request at r-project.org wrote:
> Hi,
>
> As I sit and learn how to work with time series, I've run into a problem
> that is eluding a quick easy answer (and googling for answers seems to
> really slow the process...)
>
> Question #1--
> In a simple example on R 3.3.1 (sorry my employer hasn't upgraded to 3.3.2
> yet):
>
> x=rnorm(26,0,1)
> x.ts<-ts(x,start=c(2014,9),frequency=12)
>
> inputting x.ts at the prompt gives me a table with the rooms denoted by
> year and columns denoted by months and everything lines up wonderfully.
>
> Now my problem comes when I type at the prompt
>
> plot(x.ts) or
> plot(x.ts, xlab="") or
> plot.ts(x.ts,xlab="")
>
> I get a plot of the values, but my x-axis labels are 2015.0, 2015.5,
> 2016.0, and 2016.5 . January 2015 is coming out as 2015.0...
>
> Is there a way of getting a more intelligible x-axis labeling? Even 2015.1
> for Janaury, etc. would work, or even getting an index (either Septemebr
> 2014 representing 0 or 1 and it incrementally increasing each month).
There are several ways to do this. Having some bias, I would do
require(tfplot)
tfplot(x.ts)
>
> Question #2--
> If I have a time series of decadal events, how best should I set the
> frequency. It is historical data, in the form of say AD 610-619 5 events,
> AD 620-629 7 events, etc.
For anything other than annual, quarterly, and monthly data you probably
should consider zoo. (There are other options, but I think zoo is the
most widely used for some time now.) Guessing a bit how you think of
this data, I would say you want the date index to be the first year of
the decade. To illustrate, I can generate a hundred decades of random
data and index it thus:
require(zoo)
x <- zoo(round(10 * runif(100)) , order.by= 10 * 61:160)
Paul
>
> Sorry for such a basic questions. Any advice would be appreciated.
>
> Thanks in advance, MEH
>
>
>
> Mark E. Hall, PhD
> Assistant Field Manager
> Black Rock Field Office
> Winnemucca District Office
> 775-623-1529.
More information about the R-help
mailing list