Skip to content

Fix cross-language inconsistencies; add print/fast parity#9

Open
Yicheng-Zhao1999 wants to merge 1 commit into
KMueller-Lab:mainfrom
Yicheng-Zhao1999:20260628/GMD_test_R
Open

Fix cross-language inconsistencies; add print/fast parity#9
Yicheng-Zhao1999 wants to merge 1 commit into
KMueller-Lab:mainfrom
Yicheng-Zhao1999:20260628/GMD_test_R

Conversation

@Yicheng-Zhao1999

Copy link
Copy Markdown

Cross-language consistency fixes + feature parity (R)

Aligns R/gmd.R with the Python/Stata packages and adds two options those packages
already have. Verified against live version 2026_03.

Coverage (this package = R)

# Finding Needed in R? Changed in this PR?
1 All-missing rows not dropped as documented No (R already drops all-missing rows) No
2 Variable names case-sensitive Yes Yes — case-insensitive + canonical casing
3 list/current/load keywords case-sensitive No (R already case-insensitive) No
4 Whitespace not trimmed Yes (errored) Yes — trim; empty/blank -> no filter
5 raw with a non-boolean value No (errors on "yes"/"0"; "false" -> off) No
6 sources + a variable that source lacks No (R already errors) No
7 Error precedence (version vs cite) Yes (did not validate version before cite) Yes — validates version first
print Yes (missing) Yes — added print_option
network Missing, but intentionally not added No (see below)
fast Yes (missing) Yes — added fast

What changed

Intentionally not added: network

Python/Stata's network overrides a connectivity heuristic: when their version fetch
fails they assume "offline", load a local dataset, and refuse sources/raw/cite unless
network="yes" forces them. R has no such global verdict -- it attempts each real
request independently and falls back / errors per resource. There is nothing for
network to override, so it would be a no-op in R.

Pending decision

  • Return form of metadata listing. gmd(vars=TRUE) / gmd(iso=TRUE) return a
    data.frame in R, while Python/Stata print and return None (and Python exposes
    list_variables() / list_countries() for the data). So x <- gmd(vars=TRUE) yields
    data in R but None in Python. Left as-is pending a decision on whether to align.

- Variable names matched case-insensitively and normalized to the dataset's
  canonical casing, e.g. "rgdp" -> "rGDP" (KMueller-Lab#2)
- Trim whitespace consistently with Python/Stata; blank tokens dropped and an
  empty/all-blank value becomes NULL ("no filter") instead of erroring (KMueller-Lab#4)
- Validate an invalid version before honoring cite (KMueller-Lab#7)
- Add print_option (APA citation) for parity with Python/Stata
- Add fast (local dataset cache under R_user_dir) for parity with Python/Stata

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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