Expss call returns blank table

68 Views Asked by At

Attempting to call Expss from within a function. However it returns an empty table.

s1_a<-c("a","b","b")
s1_b<-c("a","a","b")
df<-data.frame(s1_a,s1_b)


multi<-function(v) {
df %>%
tab_cells(mrset_p("v")) %>%
tab_stat_cpct() %>%
tab_sort_desc() %>%
tab_pivot()
}

multi("s1_")
1

There are 1 best solutions below

2
On BEST ANSWER

In your case you don't need quotes in the mrset_p:

library(expss)
s1_a<-c("a","b","b")
s1_b<-c("a","a","b")
df<-data.frame(s1_a,s1_b)


multi<-function(v) {
    df %>%
        tab_cells(mrset_p(v)) %>% # no quotes
        tab_stat_cpct() %>%
        tab_sort_desc() %>%
        tab_pivot()
}

multi("s1_")