On Tue, Oct 9, 2012 at 12:25 PM, Bert Gunter <gunter.berton at gene.com> wrote:
The only wrinkle here (with either rbind or simplify2array) is getting
the labels correct if the design is not fully crossed -- i.e. if some
groups are missing so that expand.grid() won't work. Then you might
have to work harder to extract the information from by.list.
Agreed. In such a case I might decide to let
aggregate(breaks~wool+tension, subset(warpbreaks, wool != 'A' | tension !=
'H' ), summary)
sort through the headache for me, and overlook the annoying "result is
actually a matrix put in as a single variable in the data.frame". Personal
preference maybe but that never made sense to me in the data frame
construct (even if it is just a list).
Cheers
might help here.
-- Bert
On Tue, Oct 9, 2012 at 11:14 AM, ilai <keren at math.montana.edu> wrote:
On Tue, Oct 9, 2012 at 11:42 AM, Rui Barradas <ruipbarradas at sapo.pt>
Hello,
Try
do.call(data.frame, by.list)
I don't think data.frame inside do.call works in this context. May need
on the outside to do the job (Only OK here since there is no mixture of
numeric and character/factors in this summary). Something like
by.list <- by(warpbreaks[, 1], warpbreaks[, -1], summary)
by.dtfrm <- data.frame( do.call( rbind, by.list ) )
by.dtfrm <- cbind( do.call( expand.grid, attr( by.list, 'dimnames' ) ),
by.dtfrm )
Hope this helps,
Rui Barradas
Em 09-10-2012 17:53, Jesus Frias escreveu:
Dear R-helpers,
I've got a summary of results from a by() call that I am making with a
of more than two of factors not very different from the example in the
help page
require(stats)
by(warpbreaks[, 1], warpbreaks[, -1], summary)
The result of the command gives a list of the form
wool: A
tension: L
Min. 1st Qu. Median Mean 3rd Qu. Max.
25.00 26.00 51.00 44.56 54.00 70.00
---------------------------------------------------
wool: B
tension: L
Min. 1st Qu. Median Mean 3rd Qu. Max.
14.00 20.00 29.00 28.22 31.00 44.00
---------------------------------------------------
.... And so on.
I would like to convert this result in to a flat data.frame with
names:
Wool, Tension, Min, 1stQ, Median, Mean, 3rdQ, Max
A, L , 25.00 26.00 51.00 44.56 54.00 70.00
B, L, 14.00 20.00 29.00 28.22 31.00 44.00
....
Although I've tried the argument "simplify=T" I haven't been able to
this converted.
Is there a simple way to achieve this?
Thanks in advance!
Regards,
Jesus
Jes?s Mar?a Fr?as Celayeta, PhD
Ceann C?nt?ir, Scoil Eola?ocht an Bhia agus Sl?inte an Chomhshaoil
Assistant Head, School of Food Science and Environmental Health,
Col?iste Eola?ochta? agus Sl?inte/ College of Sciences and Health,
Institi?id Teicneola?ochta ?tha Cliath/ Dublin Institute of
Sr?id Chathal Brugha, Baile ?tha Cliath 1, ?ire/Cathal Brugha Street,
Scanta R?omhphost de chuid Seirbh?s? Faisn?ise, ITB?C agus meastar ? a
bheith sl?n. http://www.dit.ie
This message has been scanned for content and viruses by the DIT
Information Services E-Mail Scanning Service, and is believed to be
[[alternative HTML version deleted]]