Re: [R] How to change dataframe to tables

2011-02-20 Thread Lao Meng
Well,it's my daily work on duty,not homework:) 2011/2/18 Dennis Murphy > This is a built-in dataset in R - see ?HairEyeColor and str() it. I smell > homework... > > Dennis > > On Thu, Feb 17, 2011 at 11:50 PM, Lao Meng wrote: > >> The data is in the attachment. >> >> What I wanna get is:

Re: [R] How to change dataframe to tables

2011-02-20 Thread Lao Meng
Thanks! It works well. 2011/2/18 Henrique Dallazuanna > Try this: > > xtabs(Freq ~ Hair + Eye + Sex, Dat) > > Using Dimitri's Dat example. > > On Fri, Feb 18, 2011 at 5:50 AM, Lao Meng wrote: > >> The data is in the attachment. >> >> What I wanna get is: >> , , Sex = Male >> Eye >> Ha

Re: [R] How to change dataframe to tables

2011-02-20 Thread Lao Meng
Thanks! It works well. 2011/2/18 Dimitris Rizopoulos > say, 'Dat' is your data frame, then one way to do it is: > > with(Dat, tapply(freq, list(hair, eye, sex), c)) > > > I hope it helps. > > Best, > Dimitris > > > > > On 2/18/2011 8:50 AM, Lao Meng wrote: > >> The data is in the attachment.

Re: [R] How to change dataframe to tables

2011-02-18 Thread Henrique Dallazuanna
Try this: xtabs(Freq ~ Hair + Eye + Sex, Dat) Using Dimitri's Dat example. On Fri, Feb 18, 2011 at 5:50 AM, Lao Meng wrote: > The data is in the attachment. > > What I wanna get is: > , , Sex = Male > Eye > HairBrown Blue Hazel Green > Black32 1110 3 > Brown53

Re: [R] How to change dataframe to tables

2011-02-18 Thread Dennis Murphy
This is a built-in dataset in R - see ?HairEyeColor and str() it. I smell homework... Dennis On Thu, Feb 17, 2011 at 11:50 PM, Lao Meng wrote: > The data is in the attachment. > > What I wanna get is: > , , Sex = Male > Eye > HairBrown Blue Hazel Green > Black32 1110 3

Re: [R] How to change dataframe to tables

2011-02-18 Thread Dimitris Rizopoulos
say, 'Dat' is your data frame, then one way to do it is: with(Dat, tapply(freq, list(hair, eye, sex), c)) I hope it helps. Best, Dimitris On 2/18/2011 8:50 AM, Lao Meng wrote: The data is in the attachment. What I wanna get is: , , Sex = Male Eye HairBrown Blue Hazel Green