Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.LNX.4.61.0504131718430.10084@gannet.stats>
Date: 2005-04-13T16:25:49Z
From: Brian Ripley
Subject: Behavior of apply() when used with start()
In-Reply-To: <10dee469050413073190a09e3@mail.gmail.com>

On Wed, 13 Apr 2005, Fernando Saldanha wrote:

> Can someone explain why starts1 and starts2 are diffferent in the example below?

Yes, at least one person can.  Actually, anyone who looked could:

> arr
Time Series:
Start = 1
End = 3
Frequency = 1
   tsa tsb
1   1  NA
2   2   2
3   3   3

Note the times series attributes apply to the whole matrix.

> After running this program
>
> a <- c(1:3)
> b <- c(2:3)
> tsa <- ts(a)
> tsb <- ts(b, start = 2)
> arr <- cbind(tsa, tsb)
> starts1 <- cbind(start(tsa), start(tsb))
> starts2 <- apply(arr, 2, start)
>
> I get:
>
>> starts1
>     [,1] [,2]
> [1,]    1    2
> [2,]    1    1
>
>> starts2
>     tsa tsb
> [1,]   1   1
> [2,]   1   1

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595