Nadika Dushan
Nadika Dushan

Reputation: 25

Adding a variable name for multiple-answer table expss in R / creating a variable to capture multiple answers

I want to add a variable name for the multiple-answer question Q6 which consist with 12 columns (Q6_1 to Q6_12) adding a label as follows do not give me the intended result. it adds a total_row column. I just need a label to indicate this is the table for Q6.

Alternatively if you know a way to create single variable to capture all the multiple answers, Please let me know

banner %>% 
tab_cells(mrset(Q6_1 %to% Q6_12, lablel="Q6_test")) %>%  
tab_stat_cpct() %>% 
tab_pivot() %>% 
tab_sort_desc()

enter image description here

Upvotes: 0

Views: 66

Answers (1)

Gregory Demin
Gregory Demin

Reputation: 4846

You have a typo in the your code. lablel should be label:

library(expss)

mtcars %>% 
    tab_cells(mrset(am, cyl, label = "am+cyl")) %>% 
    tab_stat_cpct() %>% 
    tab_pivot()

# |        |              | #Total |
# | ------ | ------------ | ------ |
# | am+cyl |            0 |   59.4 |
# |        |            1 |   40.6 |
# |        |            4 |   34.4 |
# |        |            6 |   21.9 |
# |        |            8 |   43.8 |
# |        | #Total cases |   32.0 |

Upvotes: 1

Related Questions