[R] constructing a data frame from ftable
Erin Hodgess
erinm.hodgess at gmail.com
Tue Jun 22 23:50:54 CEST 2010
Dear R People:
I have the following data set with the columns DATE, GENDER, and Co.
Co has 8 possible options.
> a.df[1:10,]
DATE GENDER Co
1 2009-04-16 F Rash
2 2009-04-16 F Other
3 2009-04-16 M Botulinic
4 2009-04-16 M Other
5 2009-04-16 M Constitutional
6 2009-04-16 F Other
7 2009-04-16 M Other
8 2009-04-16 M Other
9 2009-04-16 F Other
10 2009-04-16 F Other
Using ftable, I created a table by Date, Co and Gender, which is great.
> ftable(a.df$DATE,a.df$Co,a.df$GENDER)
F M
2009-04-16 Botulinic 622 631
Constitutional 1161 1124
Gastrointestinal 1020 1029
Hemorrhagic 472 477
Neurological 812 777
Other 6782 6702
Rash 607 630
Respiratory 962 1008
2009-04-17 Botulinic 690 626
Constitutional 1088 1119
Gastrointestinal 1009 984
Hemorrhagic 509 482
Neurological 735 794
Other 6682 6722
Rash 613 599
Respiratory 970 931
2009-04-18 Botulinic 519 519
Constitutional 953 964
Gastrointestinal 831 898
Hemorrhagic 416 394
Neurological 613 693
Other 5770 5749
Rash 517 522
Respiratory 794 822
2009-04-19 Botulinic 563 594
Constitutional 1039 998
Gastrointestinal 882 946
Hemorrhagic 449 451
Neurological 804 729
Other 6022 6037
Rash 545 529
Respiratory 920 877
However, (because nothing would ever be that simple), I would like to
create a data frame from the ftable output.
The data frame would have 17 columns; the first is the date, and the
remaining 16 would be a column for male/Botulinic, female/Botulinic,
and so on.
Is there a good way to do this, please?
Thanks,
Erin
--
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodgess at gmail.com
More information about the R-help
mailing list