I looked everywhere but did not find answer to my question. I am having trouble with makig contingency table. I have data with many columns, let say 1, 2 and 3. In the first column there are let say 100 different values, in the second 20 and the third column has 2 possible values: 0 and 1. First I take just data with value 1 in column 3 (data<-data[Column3==1,]). Now I have only around 20 different values in 1. column and 5 in 2. column. However when I do a contingency table its size is 100x20, not 20x5, and contains a lot of zeros (they correspond to combination of column1 and column2 which has value 0 in column3). I would be greatful for every kind of help, thanks.
Asked
Active
Viewed 170 times
-2
-
1please share example data – mtoto Mar 17 '16 at 10:06
-
Welcome to Stack Overflow! Please read the info about [how to ask a good question](http://stackoverflow.com/help/how-to-ask) and how to give a [reproducible example](http://stackoverflow.com/questions/5963269). This will make it much easier for others to help you. – zx8754 Mar 17 '16 at 11:15
1 Answers
-1
I guess all your three variables are factors.So convert them into character using
as.character()
to all three variables then apply
table()
for that.

Vamshidhar H.K.
- 198
- 1
- 7
-
Could you specify your problem little bit clearly... Or Could you explain your problem with some data and code that exists in R..?? – Vamshidhar H.K. Mar 19 '16 at 06:40