Good day,
I will appreciate your help. I am a new R user.
Kindly, I have a data set as follow (example):
|Var1|Var2|Var3|Var4|Var5|
|0|0|0|0|0|
|0|0|0|0|1|
|0|0|0|0|2|
|0|0|0|1|0|
Variables values are as follow:
Var1 bear values (0,1,2,3)
Var2, Var3, Var4, Var5 bear values (0,1,2)
I would like to build cross table that contains all possible values with its count such as follow:
|Var1|Var2|Var3|Var4|Var5|count|
|0|0|0|0|0|0|
|0|0|0|0|1|0|
|0|0|0|0|2|0|
|0|0|0|1|0|1|
|0|0|0|1|1|1|
|0|0|0|1|2|0|
|0|0|0|2|0|6|
So |0|0|0|0|0| never appear , |0|0|0|2|0| appears 6 times (6 rows) and so on.
I tried both table, crosstab and xtab but couldn't figure it out.
Regards,
Ohoud
Can you provide so usable sample data? A handy way to supply sample data is to use the dput() function. See ?dput. If you have a very large data set then something like head(dput(myfile), 100) will likely supply enough data for us to work with.