Skip to content
Prev 321072 / 398500 Next

manipulating R contingency tables

Hello,

Try the following. The first function removes a column(s) from the 
table, and the secondd all rows and columns with zero elements in them.


fun1 <- function(x, col) x[, -which(colnames(x) %in% col)]

fun2 <- function(x){
	idx <- which(x == 0, arr.ind = TRUE)
	x[-idx[, 1], -idx[, 2]]
}


Hope this helps,

Rui Barradas


Em 06-04-2013 07:55, Abhishek Pratap escreveu: