I have a "wide" dataset where for each observation I measure a value from a bunch of categorical variables. It is presented just like this:
| V1 | V2 | V3 |
|---|---|---|
| a | z | f |
| a | z | f |
| b | y | g |
| b | y | g |
| a | y | g |
| b | y | f |
this means that V1 has two categories "a" and "b", V2 has two categories "z" and "y", and so on. But suppose that I have 30 variables (a quite bigger dataset).
I want to obtain a dataset in this form
| V1 | V2 | V3 | Freq |
|---|---|---|---|
| a | z | f | 2 |
| b | y | g | 2 |
| a | y | g | 1 |
| b | y | f | 1 |
How can I get it in R? with smaller datasets I use transform(table(data.frame(data))) but it doesn't work with bigger datasets since it requires to build giant tables. Can somebody help please?
I would like to get a "general" code that does not depend on the variables name since I will be using it in a function. And moreover, since the datasets will be big I prefer to do it without the function table.
Thanks