1

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_")
CK7
  • 229
  • 1
  • 11

1 Answers1

1

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_")
Gregory Demin
  • 4,596
  • 2
  • 20
  • 20
  • Thanks. Are there cases where quotation marks would be required? – CK7 Sep 04 '20 at 09:58
  • @CK7 When you use quotes `mrset_p("v")` just search for variables which contains "v" and don't use variable `v` . So if you need to get variables with some constant pattern you can type this pattern in quotes. – Gregory Demin Sep 04 '20 at 10:47