Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Define a minimal Ctrl object
- Ctrl <- setClass("Ctrl", slots = c(item_data = "data.frame", item_names = "ANY",
- time_name = "character", geo_name = "character", group_names = "ANY",
- weight_name = "ANY", time_filter='numeric'))
- # Create minimal test data
- test_data = data.table(
- abortion = c(0, 0, 1, 2),
- year = 2018,
- state = 'MA',
- race3 = 1,
- weight = 1)
- # Instantiate a corresponding ctrl object
- ctrl = Ctrl(item_data = opinion, item_names = 'abortion', time_name = 'year',
- geo_name = 'state', group_names = 'race3', weight_name = 'weight',
- time_filter = unique(test_data$year))
- # First dichotomize
- item_data <- dichotomize(test_data, ctrl)
- # Then aggregate
- make_group_counts(item_data, NULL, ctrl)[]
Add Comment
Please, Sign In to add comment