An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20050928/a892a052/attachment.pl
is it possible to form matrix of matrices...and multiple arrays
6 messages · booop booop, venomousanimal, Gabor Grothendieck +2 more
booop booop schrieb:
Dear sirs, 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.. 2..........Is it possible to form array of array of arrays for eg.. "A" contains two set of arrays (1,2)...and each A[1] and A[2] individually contains two set of arrays I tried like p<-list() pa[[[1]]] [[1]] [1]<-matrix(1,2,2) pa[[[1]]] [[1]] [2]<-matrix(2,2,2) But its not working..kindly tell me whether my approach is wrong or not?.. kindly tell me the possible ways.. thank you.. with regards, shanmugam. --------------------------------- Click here to donate to the Hurricane Katrina relief effort. [[alternative HTML version deleted]]
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
I would say yes and yes. A Matrix with matrix entries could be a dataframe or you just use the cbind or rbind command. The array of arrays I would say is a table, then you can specify table[row,coloumn] or table[1..10,1..10]. Greetz, Sonja
On 9/28/05, booop booop <booopi at yahoo.com> wrote:
Dear sirs, 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..
Try this: mat <- list(diag(2), diag(3), diag(4), diag(5)) dim(mat) <- c(2,2) mat mat[[1,1]]
2..........Is it possible to form array of array of arrays for eg.. "A" contains two set of arrays (1,2)...and each A[1] and A[2] individually contains two set of arrays I tried like p<-list() pa[[[1]]] [[1]] [1]<-matrix(1,2,2) pa[[[1]]] [[1]] [2]<-matrix(2,2,2) But its not working..kindly tell me whether my approach is wrong or not?..
Try this. arr is set to a 2x2x2 array filled with diagonal matrices. Then we set two elements of it to constant matrices. arr <- lapply(2:9, diag) dim(arr) <- c(2,2,2) arr[[1,1,1]] arr arr[[1,1,1]] <- matrix(1,2,2) arr[[1,1,2]] <- matrix(2,2,2) arr[[1,1,1]] arr[[1,1,2]]
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).
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
Prof Brian Ripley a ??crit :
On Thu, 29 Sep 2005 vincent at 7d4.com wrote:
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)
sorry for the wrong answer, and thanks for the correction. (I certainly do not use list() as much as it should be.)