Created
July 18, 2018 00:41
-
-
Save jamesdunham/859bedc6dd283a24bc6746a859268548 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)[] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment