| To: | Jagadish Rangrej <jrangrej@yahoo.com> |
|---|---|
| Subject: | Re: Function for summarizing the table to two factors and a frequency |
| From: | David L Lorenz <lorenz@usgs.gov> |
| Date: | Thu, 8 Dec 2005 07:26:44 -0600 |
| Cc: | "s-news@lists.biostat.wustl.edu" <s-news@lists.biostat.wustl.edu> |
| In-reply-to: | <20051207221654.50085.qmail@web54414.mail.yahoo.com> |
|
Jagadish, The tapply() function will produce a summary table that you want. Note that this version return a matrix if no more than 1 value is found for n1 or n2. The I() function simply returns what is passed to it. Dave > tapply(Junk$n1, Junk[,1:2], I) 112 114 142 312 342 311 239.87344 166.50672 870.5615 120.39770 1 313 27.75878 19.03609 197.4086 35.53144 NA 341 1346.87779 553.11880 969.2233 NA NA
Hello, is there a generic function which can generate the summary table (like the one generated by 'table' function in splus/R) based on two factors and a column of counts I have a table of n x 4 out of which the 1st two are factors and other two are counts for case and control resp.. I need to generate either a table of 3 dimensions f1 x f2 x 2, or two tables of f1 x f2 size with there dimnames matched for both controls and cases. Here is an example: mydata = f1 f2 n1 n2 1 311 112 239.87344 239.829302 2 311 114 166.50672 168.512009 3 311 142 870.56154 869.301191 4 311 312 120.39770 119.280942 5 311 342 1.00000 -1.308982 6 313 112 27.75878 27.834905 7 313 114 19.03609 19.961629 8 313 142 197.40857 198.818765 9 313 312 35.53144 34.929056 10 341 112 1346.87779 1346.927249 11 341 114 553.11880 553.609228 12 341 142 969.22327 969.618471 --------------------------------------- f2 f1 112 114 142 312 342 311 1 1 1 1 1 313 1 1 1 1 0 341 1 1 1 1 1 343 1 1 1 1 0 411 1 1 1 1 0 413 0 0 1 0 0 441 1 1 1 1 0 443 1 0 0 0 0 but instead of '1's in three I need a N1, and N2's. all help will be greatly appreciated, Jag __________________________________________ Yahoo! DSL – Something to write home about. Just $16.99/mo. or less. dsl.yahoo.com -------------------------------------------------------------------- This message was distributed by s-news@lists.biostat.wustl.edu. To unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with the BODY of the message: unsubscribe s-news |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | POP Version 3 Released, Patrick Burns |
|---|---|
| Next by Date: | locate text in function(s).( summary), Kamil Toth |
| Previous by Thread: | Function for summarizing the table to two factors and a frequency, Jagadish Rangrej |
| Next by Thread: | Re: locate text in function(s), Rich |
| Indexes: | [Date] [Thread] [Top] [All Lists] |