Garavito,Fabian
2007-Jul-31 18:03 UTC
[R] Naming rows/columns in a 3 dimensional array/dataframe
Can I assign names to rows/columns in a i x k x j matrix / dataframe? This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system. If you are not the intended recipient you must not copy this message or attachment or disclose the contents to any other person. Nothing contained in the attached email shall be regarded as an offer to sell or as a solicitation of an offer to buy any services, funds or products or an expression of any opinion or views of the firm or its employees. Nothing contained in the attached email shall be deemed to be an advise of, or recommendation by, the firm or its employees. No representation is made as to accuracy, completeness, reliability or appropriateness of the information contained in the attached email. [[alternative HTML version deleted]]
Marc Schwartz
2007-Jul-31 20:35 UTC
[R] Naming rows/columns in a 3 dimensional array/dataframe
On Tue, 2007-07-31 at 19:03 +0100, Garavito,Fabian wrote:> Can I assign names to rows/columns in a i x k x j matrix / dataframe?You can use an array: ARR <- array(1:18, c(3, 3, 3), dimnames = list(LETTERS[1:3], LETTERS[4:6], LETTERS[7:9]))> ARR, , G D E F A 1 4 7 B 2 5 8 C 3 6 9 , , H D E F A 10 13 16 B 11 14 17 C 12 15 18 , , I D E F A 1 4 7 B 2 5 8 C 3 6 9> ARR["B", "E", "H"][1] 14 See ?array By definition, matrices and dataframes are two dimensional, though you can have a list containing N of them. HTH, Marc Schwartz
Possibly Parallel Threads
- Error message when running lm() with na.action=NULL
- Boxplots from 4 dimensional array
- which is the fastest way to make data.frame out of a three-dimensional array?
- Chopping a two column data frame by rows into a three dimensional array.
- how to cut a multidimensional array along a chosen dimension and store each piece into a list