Skip to content

frequency table-visualization for complex categorical variables

6 messages · Anthony Damico, Rui Barradas, Niklas Fischer

#
Hello,

I disagree with the way you've sorted the matrix, like this all A's 
become first, then B's, etc, irrespective of the respondents. Each row 
is a respondent, and the rows should be kept intact, but with a 
different ordering. To this effect, use order():

z <- y[order(y[,1], y[,2], y[,3]), ]


Then use the rest of your code.

Or, which would save us the sorting, paste the rows elements together 
directly from matrix 'y' and use the fact that table() sorts its output.

w2 <- apply( y , 1 , paste0 , collapse = "" )
table(w2)


Hope this helps,

Rui Barradas

Em 25-02-2013 18:32, Anthony Damico escreveu:
#
Hello,

I'm not sure I understand, do you want to treat BCC, CBC and CCB as the 
same? If so try

w2 <- apply( y , 1 , function(x) paste0(sort(x) , collapse = "" ))
table(w2)


Hope this helps,

Rui Barradas

Em 26-02-2013 13:58, Niklas Fischer escreveu: