Ernst Linder's suggestion was simple and worked well.
Thanks, Ernst.
|---------+---------------------------->
| | Ernst Linder |
| | <elinder@cisunix.|
| | unh.edu> |
| | |
| | 07/22/2005 10:52 |
| | AM |
| | |
|---------+---------------------------->
>----------------------------------------------------------------------------------------------------------------------------|
|
|
| To: TzamouranisY@LouisDreyfus.com
|
| cc:
|
| Subject: Re: [S] old format of time series
|
>----------------------------------------------------------------------------------------------------------------------------|
Hi:
It's very simple. Just use the matrix command.
(note that rows and columns need to be interchanged)
You will need to assign the dimnames to the matrix.
But that is not very difficult either.
Here is a little program that works:
uuu <- ts(rnorm(36),start=1989,freq = 12)
tsmat <- t(matrix(uuu,nrow=12));
dimnames(tsmat)[[2]] <- levels(months(1))
dimnames(tsmat)[[1]] <- 1989:1991
HTH
EL
TzamouranisY@LouisDreyfus.com wrote:
> The old(er) "ts" function in SPLUS has some advantages over new
functions.
> The main advantage I find - and still use it for this - is the formating:
> Jan Feb Mar Apr May Jun Jul
> Aug Sep Oct Nov Dec
> 1985: 336.1270 321.5090 329.6240 341.9080 356.6300 344.0580 326.9770
> 318.4740 317.3650 313.6870 320.9430 320.8920
> 1986: 331.6770 331.7240 340.9000 337.7910 328.6400 326.6540 341.7980
> 332.7130 337.7990 343.8920 339.0840 331.2240
> 1987: 333.0290 331.8580 332.4510 328.9570 324.7030 327.5980 323.7500
> 332.4680 337.1640 355.8940 363.6370 348.9950
> 1988: 345.5830 348.0210 354.0030 357.3770 359.6650 358.8580 349.4900
> 333.5640 328.5600 339.5880 337.0140 330.3590
>
> When the time series is inserted in reports , it allows you to see
> seasonality and year-over-year trends for particular months.
> Nevertheless, that is only true when it is printed.
> Does anyone have a simple way to create a matrix of that exact format?
> I looked at the printing method - but that is hidden in C and could not
> find a way to use it to return a matrix or data frame where:
> - the rows would be named by the year
> - the columns would be named after the month.
> I can imagine a complex way of doing this (breaking the data by year,
> making a matrix by appending rows, naming the rows and the columns, etc).
> Is there something more trivial that I am missing?
>
> Thanks,
>
> Yannis Tzamouranis
>
> --------------------------------------------------------------------
> This message was distributed by s-news@lists.biostat.wustl.edu. To
> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
> the BODY of the message: unsubscribe s-news
>
--
****************************************************************
Ernst Linder elinder@math.unh.edu
Department of Mathematics and Statistics 603 - 862- 2687
University of New Hampshire Fax: 603 - 862 - 4096
Durham, NH 03824 www.math.unh.edu/~elinder
****************************************************************
|