Thanks for that, but the documentation also says that teh default behaviour is
to use na.action=na.pass, which normally just ignores missing values, whereas
xtabs seems to ignore the entire row...
/Bendix
From: David L Carlson
Sent: 25 April 2019 15:55
The documentation describes how to control the behavior of missing values:
> xtabs( cbind(xx,yy) ~ ff, addNA=TRUE)
ff xx yy
a 17
b 55 66
But of course, now you do not get 26 in the (a, yy) cell because 26 + NA = NA.
David L Carlson
Here is an example showing that xtabs and cbind are not commutative, which at
least I thought reading the help page for xtabs.
print( sessionInfo(), l=F )
xx <- c( 6,11,38,17)
yy <- c(NA,26,18,48)
ff <- c('a','a','b','b')
data.frame( xx, yy, ff )
xtabs( cbind(xx,yy) ~ ff )
cbind( xtabs(xx ~ ff
3 matches
Mail list logo