[R] How to change dataframe to tables

Lao Meng laomeng.3 at gmail.com
Fri Feb 18 08:50:47 CET 2011


The data is in the attachment.

What I wanna get is:
, , Sex = Male
       Eye
Hair    Brown Blue Hazel Green
  Black    32   11    10     3
  Brown    53   50    25    15
  Red      10   10     7     7
  Blond     3   30     5     8
, , Sex = Female
       Eye
Hair    Brown Blue Hazel Green
  Black    36    9     5     2
  Brown    66   34    29    14
  Red      16    7     7     7
  Blond     4   64     5     8


Then,how to change the dataframe to tables?

Many thanks for your help.

Best
-------------- next part --------------
"hair"	"eye"	"sex"	"freq"
"Black"	"Brown"	"Male"	32
"Black"	"Blue"	"Male"	11
"Black"	"Hazel"	"Male"	10
"Black"	"Green"	"Male"	3
"Brown"	"Brown"	"Male"	38
"Brown"	"Blue"	"Male"	50
"Brown"	"Hazel"	"Male"	25
"Brown"	"Green"	"Male"	15
"Red"	"Brown"	"Male"	10
"Red"	"Blue"	"Male"	10
"Red"	"Hazel"	"Male"	7
"Red"	"Green"	"Male"	7
"Blond"	"Brown"	"Male"	3
"Blond"	"Blue"	"Male"	30
"Blond"	"Hazel"	"Male"	5
"Blond"	"Green"	"Male"	8
"Black"	"Brown"	"Female"	36
"Black"	"Blue"	"Female"	9
"Black"	"Hazel"	"Female"	5
"Black"	"Green"	"Female"	2
"Brown"	"Brown"	"Female"	81
"Brown"	"Blue"	"Female"	34
"Brown"	"Hazel"	"Female"	29
"Brown"	"Green"	"Female"	14
"Red"	"Brown"	"Female"	16
"Red"	"Blue"	"Female"	7
"Red"	"Hazel"	"Female"	7
"Red"	"Green"	"Female"	7
"Blond"	"Brown"	"Female"	4
"Blond"	"Blue"	"Female"	64
"Blond"	"Hazel"	"Female"	5
"Blond"	"Green"	"Female"	8


More information about the R-help mailing list