I am doing this research using RStudio that can generate/tabulate labels that will also show 0 counts. I am using the 'cro and 'calc_cro function in RStudio.
My sample codes:
S4 <- cro(data$S4, list(total(), data$S3A_1, data$User, data$S4, data$S8rev, data$S5rev))
and
S9 <- calc_cro(data, mrset(S9_1 %to% S9_993_1),list(total(), S3A_1, User, S4, S8rev, S5rev))
For example, S4 is a variable code for size, i.e. (1 - Small, 2 - Medium, 3 - Large).
Moreover, sample survey results show only small and large respondents. My codes results will be more like this:
Size | Total | Male | Female | ... |
---|---|---|---|---|
Small | 15 | 8 | 7 | ... |
Large | 15 | 8 | 7 | ... |
Can someone help me to modify my codes that are using to show also labels with 0 counts like this:
Size | Total | Male | Female | ... |
---|---|---|---|---|
Small | 15 | 8 | 7 | ... |
Medium | 0 | 0 | 0 | ... |
Large | 15 | 8 | 7 | ... |
I am thinking right now that this is not possible because R can't determine the range of the labels (in my example 1-3, how would it know that it is 1 to 3 and doesn't have 4,5,..., x number of labels).
However, there are still thoughts in my head saying if I can define/include the range in my codes, would it be possible to make this work?
Here's my dput
...
structure(list(RespID = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30), S4 = c(1, 3, 3, 3, 3, 3, 3, 1, 3, 1, 1, 1, 3, 3,
1, 3, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1), Gender = c(1,
1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1, 2, 1, 2,
2, 1, 2, 1, 1, 2, 2, 2), Area = c(2, 2, 2, 4, 1, 1, 3, 4, 1,
1, 1, 4, 2, 3, 1, 3, 3, 1, 3, 4, 1, 3, 3, 4, 4, 3, 1, 1, 4, 1
)), row.names = c(NA, -30L), class = c("tbl_df", "tbl", "data.frame"
))
With data labels:
S4 = {1 - Small, 2 - Medium, 3 - Large}
Gender = {1 - Male, 2 - Female}
Area = {1 - North, 2 - East, 3 - South, 4 - North}