Skip to content

Code review: 01-demographic.R#5

Merged
martindanka merged 2 commits intomainfrom
review/01-demographic
Mar 25, 2026
Merged

Code review: 01-demographic.R#5
martindanka merged 2 commits intomainfrom
review/01-demographic

Conversation

@martindanka
Copy link
Copy Markdown
Contributor

Fixes

  • Ethnicity: Changed the mapping for code -94 from "Script error/information lost" to "Don't know/insufficient information" (now coded as -8) to reflect the documentation.
  • Sexual orientation:
    • For S6 and S7 (sori19, sori20), codes -100 and -97 (declined sexual experience questions / refused self-completion) now map to -9 (“Refusal”) rather than -3.
    • Code -91 is now consistently treated as -1 (“Item not applicable”) instead of -8 (“Don’t know / insufficient information”).
    • For S8 (sori25), code -1 (“Not applicable”) is now kept as -1 (“Item not applicable”) instead of being merged into -8 ("Don't know/insufficient information").
    • For S9 (sori32), code 5 (“Prefer not to say”) is now mapped to -7 ("Prefer not to say"), which is consistent with documentation. Code -1 is now kept as “Item not applicable” rather than merged into -8 ("Don't know/insufficient information").
  • Partnership status: Re-written using look-up tables to make the mapping very explicit. This was needed because the source variables are inconsistent in values/labels, so some substantive and missing categories were getting remapped incorrectly. I have also added cross-checks for the derived variables.

Improvements

  • All derived variables now stored as haven::labelled rather than factors, so that values/labels match the documentation.
  • Removed redundant is.na() checks and simplified some case_when() logic.

@martindanka martindanka requested review from dbann and fwwu December 20, 2025 02:18
@martindanka martindanka self-assigned this Dec 20, 2025
@martindanka martindanka force-pushed the review/01-demographic branch from 3a79610 to 1b85834 Compare March 25, 2026 18:45
@martindanka martindanka merged commit 16af8ec into main Mar 25, 2026
@martindanka martindanka deleted the review/01-demographic branch April 27, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant