Guest User

Untitled

a guest
Jul 17th, 2018
997
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. # Define a minimal Ctrl object
  2. Ctrl <- setClass("Ctrl", slots = c(item_data = "data.frame", item_names = "ANY",
  3. time_name = "character", geo_name = "character", group_names = "ANY",
  4. weight_name = "ANY", time_filter='numeric'))
  5.  
  6. # Create minimal test data
  7. test_data = data.table(
  8. abortion = c(0, 0, 1, 2),
  9. year = 2018,
  10. state = 'MA',
  11. race3 = 1,
  12. weight = 1)
  13.  
  14. # Instantiate a corresponding ctrl object
  15. ctrl = Ctrl(item_data = opinion, item_names = 'abortion', time_name = 'year',
  16. geo_name = 'state', group_names = 'race3', weight_name = 'weight',
  17. time_filter = unique(test_data$year))
  18.  
  19. # First dichotomize
  20. item_data <- dichotomize(test_data, ctrl)
  21.  
  22. # Then aggregate
  23. make_group_counts(item_data, NULL, ctrl)[]
Add Comment
Please, Sign In to add comment