[R] bi-monthly time series
Michael Friendly
friendly at yorku.ca
Thu Feb 20 21:03:37 CET 2014
The vector, vec, below represents a time series of the number of some
events recorded
for 208 two-week intervals from 2005/01/01 up to the end of 2012. I
want to
represent this together with the date information. I tried ts(), but
don't quite understand
how to use the start=, end= and frequency= arguments in this case.
vec <- c(
1L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 2L, 0L, 1L, 0L, 3L, 1L, 1L,
2L, 0L, 0L, 1L, 0L, 0L, 0L, 3L, 0L, 2L, 0L, 1L, 0L, 1L, 0L, 0L,
1L, 1L, 0L, 1L, 0L, 1L, 1L, 0L, 0L, 3L, 0L, 0L, 3L, 1L, 1L, 1L,
0L, 1L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 3L, 0L, 1L, 1L, 1L, 0L, 0L,
0L, 1L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 1L, 0L, 0L, 0L, 2L, 1L, 0L,
1L, 0L, 1L, 0L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L,
0L, 1L, 1L, 0L, 1L, 0L, 2L, 0L, 2L, 0L, 1L, 1L, 0L, 0L, 0L, 0L,
2L, 0L, 1L, 1L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L,
0L, 1L, 0L, 1L, 0L, 1L, 1L, 0L, 2L, 0L, 1L, 1L, 0L, 1L, 0L, 0L,
0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L,
0L, 0L, 1L, 1L, 1L, 2L, 0L, 1L, 1L, 1L, 0L, 0L, 2L, 0L, 0L, 0L,
0L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 2L, 0L, 0L,
1L, 0L, 0L, 0L, 2L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L,
0L)
This is what I tried, but it doesn't seem right because str() reports
... to 2014.
> vec.ts <- ts(vec,
+ start=c(2005,1),
+ frequency=24
+ )
>
> str(vec.ts)
Time-Series [1:208] from 2005 to 2014: 1 0 0 0 1 1 1 0 2 0 ...
>
If instead of a time series, I attached date names to the observations,
they would be something
like
names(vect) <- seq(as.Date('2005/01/01'),as.Date('2013/01/01'),by=14)
but that's awkward to work with.
--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, Quantitative Methods
York University Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele Street Web: http://www.datavis.ca
Toronto, ONT M3J 1P3 CANADA
More information about the R-help
mailing list