Skip to content

Commit bd9d1ca

Browse files
committed
prevent raceeth missing error
1 parent 3a425fe commit bd9d1ca

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

facebook/delphiFacebook/R/responses.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,12 @@ create_complete_responses <- function(input_data, county_crosswalk)
544544
"zip5" # temporarily; we'll filter by this column later and then drop it before writing
545545
)
546546

547+
# Remove "raceethnicity" from cols_to_report if not producing race-ethnicity
548+
# microdata so we don't get an error that the field doesn't exist.
549+
if (is.null(params$produce_individual_raceeth) || !params$produce_individual_raceeth) {
550+
cols_to_report <- cols_to_report[cols_to_report != "raceethnicity"]
551+
}
552+
547553
# Not all cols are present in all waves; if our data does not include some
548554
# questions, don't report them.
549555
if (any(!(cols_to_report %in% names(input_data)))) {

0 commit comments

Comments
 (0)