Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.LNX.4.61.0509290955240.13451@gannet.stats>
Date: 2005-09-29T08:59:26Z
From: Brian Ripley
Subject: is it possible to form matrix of matrices...and multiple arrays
In-Reply-To: <433B861A.8080501@7d4.com>

On Thu, 29 Sep 2005 vincent at 7d4.com wrote:

> booop booop a ?crit :
>
>> 1...........Kindly tell me is it possible to form
>> a matrix which contains a no of matrices.. for eg..
>> if a,b,c,d are matrices....
>> and e is a matrix which contains a,b,c,d as rows and columns..
>
> I don't think you can use matrix() to store other matrix() inside.
> But array() is a solution to store matrix() inside.
> (At least I have use it).

You _can_ do this with matrix() (although that was not quite what was 
asked). Try

a <- b <- c <- d <- matrix(1:4, 2, 2)
e <- matrix(list(a,b,c,d), 2,2)
e
e[1,2][[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