tests/tests.R

library(tidyverse)

wants <- read_csv("tests/test_multi.csv") %>%
  arrange(`Response ID`) %>%  mutate(a=rep(1:3,93))

wants$b=1
wants$b[198:279]=2



# this is the basic use
wants %>% prop_multi(area_wants) %>% view()


# when the data is pre grouped, the total n would be calculated out of the pre defined groupes
# warning will be shown since this is a risky behavior
wants_grouped <- wants %>%
   group_by(a)

wants_grouped %>% prop_multi(area_wants) %>% view()


wants_grouped_other <- wants %>%  group_by(b)
#those are equivalent
wants_grouped_other %>% prop_multi(area_wants) %>% view()
wants_grouped_other %>%  prop_multi(b,area_wants) %>% view()


# the use of pre grouping might yield odd results
wants_grouped <- wants %>%
  group_by(a,area_wants)

wants_grouped %>% prop_multi(area_wants) %>% view()

# missuse ends in error to keep data integrity
wants %>% prop_multi() %>% view()

wants %>% prop_multi(idvar = "Response ID") %>% view()
sarid-ins/saridr documentation built on Nov. 10, 2020, 9:07 p.m.