[R] Change the result data

Muhammad Subianto subianto at cs.uu.nl
Fri Feb 27 12:28:20 CET 2004


Dear R-helper,

I have a data like:

 > hec.data <-array(c(5,15,20,68,29,54,84,119,14,14,17,26,16,10,94,7),
+            dim=c(4,4),
+            dimnames=list(eye=c("Green","Hazel", "Blue", "Brown"),
+            hair=c("Black", "Brown", "Red", "Blond")))
 > hec.data
       hair
eye     Black Brown Red Blond
  Green     5    29  14    16
  Hazel    15    54  14    10
  Blue     20    84  17    94
  Brown    68   119  26     7
 >

but I want the result like below.:

hair   eye counts
Black Green    5
Black Hazel   15
Black  Blue   20
Black Brown   68
Brown Green   29
Brown Hazel   54
Brown  Blue   84
Brown Brown  119
Red Green     14
Red Hazel     14
Red  Blue     17
Red Brown     26
Blond Green   16
Blond Hazel   10
Blond  Blue   94
Blond Brown    7

How can I do it. Thanks you for your help.

Best regards,
Muhammad Subianto




More information about the R-help mailing list