Skip to content

Add dataset-level attribute comparison support (#148) - #151

Open
botsp wants to merge 2 commits into
gowerc:masterfrom
botsp:feat/issue-148-dataset-label-check
Open

Add dataset-level attribute comparison support (#148)#151
botsp wants to merge 2 commits into
gowerc:masterfrom
botsp:feat/issue-148-dataset-label-check

Conversation

@botsp

@botsp botsp commented Sep 8, 2026

Copy link
Copy Markdown

Summary

This PR implements #148 by adding dataset-level attribute comparison in diffdf(), so differences such as dataset label (e.g., DM = "Demographics") can be detected and reported.

Closes #148.

What changed

  • Added a new internal helper in R/identify.R:
    • identify_df_att_differences(BASE, COMP, exclude_attrs = c("names", "row.names", "class"))
    • Compares dataframe-level attributes between BASE and COMPARE.
  • Updated R/diffdf.R:
    • Captures dataframe-level attribute differences early in the workflow.
    • Adds a new issue component:
      • DataframeAttribDiffs
      • message: BASE and COMPARE dataframes have differing attributes !!
  • Updated tests in tests/testthat/test-core.R:
    • Added checks that dataframe-level label differences trigger warnings.
    • Added checks that DataframeAttribDiffs has expected row count.

Validation

Unit test (local source)

  • testthat::test_local('.', filter = 'core')
  • Result: PASS (102)

Real XPT checks (3 scenarios)

Using SDTM XPT examples, validated:

  1. Fully consistent datasets
    • Result: No issues were found!
  2. Dataset label inconsistent
    • Result: DataframeAttribDiffs reports label difference.
  3. Dataset label + variable label inconsistent
    • Result: Both dataframe-level and variable-level attribute differences are reported in print output.

Notes

  • Existing variable-level attribute comparison (AttribDiffs) behavior is preserved.
  • This PR only adds dataset-level attribute detection/reporting and related tests.

@gowerc

gowerc commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Hey @botsp ,

Thanks for this looks good, only remark from me would be could we just have a print test for more complex attributes to make sure it doesn't break the print method. I mean the code is basically the same construct as what is already used so I suspect its fine but would be good to just assert so with a test.

@botsp

botsp commented Sep 9, 2026

Copy link
Copy Markdown
Author

hi @gowerc Thanks for the review. Yes -- for #148 I intentionally followed the existing code structure used in the package. And thanks for the kind reminder, I also added print regression tests for dataframe-level attributes (including complex nested attributes, NULL vs non-NULL, character vector attributes, and a Japanese dataset label case) to confirm the print path remains stable.
Could you please take another look when you have a chance?

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.

Check the label attribute of the dataset

2 participants