Skip to content

Commit

Permalink
setting to single_row to true for summarize_by checkbox vars
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobmoore5067 committed Jan 19, 2024
1 parent d153aad commit 3eeac5b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions R/hts_prep_byvar.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ hts_prep_byvar = function(summarize_by = NULL,
wide_dt = byvar_dt_v,
shared_name_vars = NULL,
variables_dt = variables_dt,
to_single_row = TRUE,
...
)

Expand Down
10 changes: 6 additions & 4 deletions R/hts_prep_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -200,20 +200,22 @@ hts_prep_data = function(summarize_var = NULL,

for (i in 1:length(summarize_by)){

byvar_location = hts_find_var(summarize_by[i], variables_dt = variables_dt)
var = summarize_by[i]

byvar_location = hts_find_var(var, variables_dt = variables_dt)

# Select table where this variable lives:
byvar_table = data[[byvar_location]]

byvar_is_shared = variables_dt[shared_name == summarize_by[i], is_checkbox][1] == 1
byvar_is_shared = variables_dt[shared_name == var, is_checkbox][1] == 1

if (byvar_is_shared) {

summarize_by[i] = variables_dt[shared_name == summarize_by[i], variable][1]
var = variables_dt[shared_name == var, variable][1]

}

if(byvar_table[,class(get(summarize_by[i]))] != 'integer'){
if(byvar_table[,class(get(var))] != 'integer'){

message("Checkbox variables must have integer values")

Expand Down

0 comments on commit 3eeac5b

Please sign in to comment.