[R] Naming rows/columns in a 3 dimensional array/dataframe

2007-07-31 Thread Garavito,Fabian
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]]

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Naming rows/columns in a 3 dimensional array/dataframe

2007-07-31 Thread Marc Schwartz
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

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.