I have a logical matrix x with named rows (\'a\' and \'b\') and named columns (\'10\', \'20\', \'30\', \'40\'). Let\'s say, this:
x
10 20 3
You can directly use apply.
apply
apply( x, 1, function(u) paste( names(which(u)), collapse="," ) )