| To: | "Liaw, Andy" <andy_liaw@merck.com>, "'Xao Ping'" <xao_ping@yahoo.com>, s-plus user list <s-news@lists.biostat.wustl.edu> |
|---|---|
| Subject: | Re: transforming 2D matrix to 4D array |
| From: | "Richard M. Heiberger" <rmh@temple.edu> |
| Date: | Wed, 16 Feb 2005 22:00:56 -0500 |
If it is already sorted correctly, then it can be done even faster than
Andy suggested by just assigning the new dimensions.
> m <- matrix(1:16, 2, 8)
> m
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] 1 3 5 7 9 11 13 15
[2,] 2 4 6 8 10 12 14 16
> dim(m) <- c(2,2,2,2)
> m
, , 1, 1
[,1] [,2]
[1,] 1 3
[2,] 2 4
, , 2, 1
[,1] [,2]
[1,] 5 7
[2,] 6 8
, , 1, 2
[,1] [,2]
[1,] 9 11
[2,] 10 12
, , 2, 2
[,1] [,2]
[1,] 13 15
[2,] 14 16
>
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: transforming 2D matrix to 4D array, Liaw, Andy |
|---|---|
| Next by Date: | Re: S-Plus 2000 under Windows XP?, Prof Brian Ripley |
| Previous by Thread: | Re: transforming 2D matrix to 4D array, Liaw, Andy |
| Next by Thread: | transforming 2D matrix to 4D array, Xao Ping |
| Indexes: | [Date] [Thread] [Top] [All Lists] |