s-news
[Top] [All Lists]

convertion of result of tapply() to data frame

To: s-news@lists.biostat.wustl.edu
Subject: convertion of result of tapply() to data frame
From: Vadim Ogranovich <vograno@arbitrade.com>
Date: Fri, 27 Jul 2001 16:00:16 -0500
Dear S-Users, I tapply "summary" function to a vector and get back a list of
vectors of length six as a result. So far so good. Then I want to convert
this list to a data frame (actually to a matrix)and instead of getting a 2*6
data frame I have a 1*12 one. Any suggestion why? Thanks, Vadim


> x <- seq(1,20)
> f <- rep(c(T,F), 10)
> l <- tapply(x, f, summary)
> l
$FALSE:
   Min. 1st Qu. Median   Mean 3rd Qu.   Max. 
 " 2.0"  " 6.5" "11.0" "11.0"  "15.5" "20.0"

$TRUE:
   Min. 1st Qu. Median   Mean 3rd Qu.   Max. 
 " 1.0"  " 5.5" "10.0" "10.0"  "14.5" "19.0"

> data.frame(l)
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] 
    2  6.5   11   11 15.5   20    1  5.5   10    10  14.5    19
> mode(l)
[1] "list"
> class(l)
[1] "named"
        

-------------------------------------------------- 
DISCLAIMER 
This e-mail, and any attachments thereto, is intended only for use by the
addressee(s) named herein and may contain legally privileged and/or
confidential information.  If you are not the intended recipient of this
e-mail, you are hereby notified that any dissemination, distribution or
copying of this e-mail, and any attachments thereto, is strictly prohibited.
If you have received this e-mail in error, please immediately notify me and
permanently delete the original and any copy of any e-mail and any printout
thereof. 

E-mail transmission cannot be guaranteed to be secure or error-free.  The
sender therefore does not accept liability for any errors or omissions in
the contents of this message which arise as a result of e-mail transmission.

NOTICE REGARDING PRIVACY AND CONFIDENTIALITY 

Knight Trading Group may, at its discretion, monitor and review the content
of all e-mail communications. 


<Prev in Thread] Current Thread [Next in Thread>