[R] margin.table

Jagat Sheth shethj at epi.wustl.edu
Mon Jul 2 14:55:39 CEST 2001


Hello all, 

I was wondering if the following behaviour of margin.table in R 1.3.0 is normal.

> mm <- data.frame(x=c(0,0,1), y=c(1,1,0), z=c(0,1,0))
> margin.table(mm,1)
[1] 1 2 3
<0 rows> (or 0-length row.names)

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

> apply(mm,1,sum)
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.

> mmm <- as.matrix(mm)
> margin.table(mmm,1)
1 2 3 
1 2 1 
> margin.table(mmm,2)
x y z 
1 2 1 

I am using 

> version
         _              
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list