Skip to content

margin.table

3 messages · Brian Ripley, Jagat Sheth, Peter Dalgaard

#
On Mon, 2 Jul 2001, Jagat Sheth wrote:

            
Yes.
Try looking up the help page:

Arguments:

       x: an array


A data frame is *not* an array:
[1] FALSE

and final line of margin.table tries to make the result make into a
data frame.

One could argue that as it accepted a non-array it should do a better job
with it, but we need the author (who is away this week) to explain why
he copied the class of the first argument to the result.
#
Hello all, 

I was wondering if the following behaviour of margin.table in R 1.3.0 is normal.
[1] 1 2 3
<0 rows> (or 0-length row.names)

while using 'apply(x,margin,sum)' I get
1 2 3 
1 2 1 

which appears to be normal. Similar behaviour when margin=2.

On the other hand, the following seems to be fine.
1 2 3 
1 2 1
x y z 
1 2 1 

I am using
_              
platform i386-pc-mingw32
arch     x86            
os       Win32          
system   x86, Win32     
status                  
major    1              
minor    3.0            
year     2001           
month    06             
day      22             
language R    
 
I did not notice the above behaviour with R 1.2.3 and have not found anything in the windows-specific changes to R documentation for R 1.3.0 regarding this. Please let me know if I am overlooking something obvious. Any advice would be appreciated. Thanks. 

Jagat 



Department of Psychiatry
Washington University in St. Louis
St. Louis, MO 63108
USA
Tel: 314-286-2253
Fax: 314-286-2265
email: shethj at epi.wustl.edu


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:
Because Kurt (who's also away this week) asked him to... It's to
preserve "xtabs" and "table" classes on the result. Data frames never
entered my mind and I don't think you should reasonably expect them to
work.