Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add as_card() function to convert to class 'card' #292

Merged
merged 12 commits into from
Aug 20, 2024
Merged

Conversation

edelarua
Copy link
Contributor

@edelarua edelarua commented Aug 13, 2024

What changes are proposed in this pull request?

Closes #283 and #287


Pre-review Checklist (if item does not apply, mark is as complete)

  • All GitHub Action workflows pass with a ✅
  • PR branch has pulled the most recent updates from master branch: usethis::pr_merge_main()
  • If a bug was fixed, a unit test was added.
  • Code coverage is suitable for any new functions/features (generally, 100% coverage for new code): devtools::test_coverage()
  • Request a reviewer

Reviewer Checklist (if item does not apply, mark is as complete)

  • If a bug was fixed, a unit test was added.
  • Run pkgdown::build_site(). Check the R console for errors, and review the rendered website.
  • Code coverage is suitable for any new functions/features: devtools::test_coverage()

When the branch is ready to be merged:

  • Update NEWS.md with the changes from this pull request under the heading "# cards (development version)". If there is an issue associated with the pull request, reference it in parentheses at the end update (see NEWS.md for examples).
  • All GitHub Action workflows pass with a ✅
  • Approve Pull Request
  • Merge the PR. Please use "Squash and merge" or "Rebase and merge".

@edelarua edelarua added the sme label Aug 13, 2024
Copy link
Contributor

github-actions bot commented Aug 13, 2024

Unit Tests Summary

  1 files  105 suites   29s ⏱️
102 tests  67 ✅ 35 💤 0 ❌
226 runs  175 ✅ 51 💤 0 ❌

Results for commit cb224ce.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Aug 13, 2024

Unit Test Performance Difference

Test Suite $Status$ Time on main $±Time$ $±Tests$ $±Skipped$ $±Failures$ $±Errors$
as_card 👶 $+0.00$ $+1$ $+1$ $0$ $0$
selectors 💚 $1.23$ $-1.15$ $0$ $0$ $0$ $0$
Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
as_card 👶 $+0.02$ as_card_does_not_affect_card_objects
as_card 👶 $+0.00$ as_card_error_catching_works_correctly
as_card 👶 $+0.23$ as_card_works
selectors 💚 $1.23$ $-1.15$ selectors_work

Results for commit 5d0f96f

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Aug 13, 2024

badge

Code Coverage Summary

Filename                       Stmts    Miss  Cover    Missing
---------------------------  -------  ------  -------  -----------------------------------
R/apply_fmt_fn.R                  95      24  74.74%   36-43, 109-116, 198-205
R/ard_attributes.R                35       1  97.14%   56
R/ard_categorical.R              348      21  93.97%   233, 390-394, 401-402, 563-578, 612
R/ard_complex.R                   36       1  97.22%   79
R/ard_continuous.R               176       4  97.73%   118, 200-201, 299
R/ard_dichotomous.R               80       8  90.00%   62, 150-155, 178
R/ard_hierarchical.R              83       0  100.00%
R/ard_missing.R                   58       1  98.28%   50
R/ard_stack.R                     84       7  91.67%   107, 186-191
R/ard_total_n.R                   10       0  100.00%
R/as_card.R                        5       0  100.00%
R/as_nested_list.R                41       0  100.00%
R/bind_ard.R                      22       3  86.36%   51-53
R/check_ard_structure.R           39       6  84.62%   31, 55-59
R/default_stat_labels.R           18       0  100.00%
R/eval_capture_conditions.R       18       0  100.00%
R/get_ard_statistics.R            16       1  93.75%   75
R/nest_for_ard.R                  71       1  98.59%   60
R/print_ard_conditions.R          75      66  12.00%   60-176
R/print.R                         72       0  100.00%
R/process_selectors.R            126       1  99.21%   337
R/replace_null_statistic.R        11       0  100.00%
R/round5.R                         1       0  100.00%
R/selectors.R                     14       0  100.00%
R/shift_ard_columns.R             77      13  83.12%   61, 69, 144-147, 150-156
R/shuffle_ard.R                  102       0  100.00%
R/summary_functions.R             25       1  96.00%   59
R/tidy_ard_order.R                25       0  100.00%
R/tidy_as_ard.R                   39      11  71.79%   88-98
R/utils.R                         24       0  100.00%
TOTAL                           1826     170  90.69%

Diff against main

Filename           Stmts    Miss  Cover
---------------  -------  ------  --------
R/ard_complex.R       +2      +1  -2.78%
R/ard_missing.R       +2      +1  -1.72%
R/as_card.R           +5       0  +100.00%
TOTAL                 +9      +2  -0.06%

Results for commit: cb224ce

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@edelarua edelarua requested a review from ddsjoberg August 19, 2024 20:08
@ddsjoberg
Copy link
Collaborator

Ahhh, thank you for adding this!!

One thing I encountered while prepping the first CSR was that sometimes our ard_*() functions return an empty tibble, e.g. dplyr::tibble(), which are just class tibble (not card).

The issue occurs when we stack one of these empty tibble on top of a card data frame, we lose the card class.

I was thinking we should also add the card class to these empty tibbles. What do you think? For example,

  # return empty tibble if no variables selected -------------------------------
  if (is_empty(variables)) {
    return(dplyr::tibble() |> as_card())
  }

BUT this may cause issues in the card print method (i haven''t check though).

@edelarua
Copy link
Contributor Author

Ahhh, thank you for adding this!!

One thing I encountered while prepping the first CSR was that sometimes our ard_*() functions return an empty tibble, e.g. dplyr::tibble(), which are just class tibble (not card).

The issue occurs when we stack one of these empty tibble on top of a card data frame, we lose the card class.

I was thinking we should also add the card class to these empty tibbles. What do you think? For example,

  # return empty tibble if no variables selected -------------------------------
  if (is_empty(variables)) {
    return(dplyr::tibble() |> as_card())
  }

BUT this may cause issues in the card print method (i haven''t check though).

Good call! I can't see any issues with the print method, but I think it makes sense to return an empty ARD where we can. I've added the as_card() call to the empty tibble return sections where needed.

@edelarua edelarua linked an issue Aug 20, 2024 that may be closed by this pull request
Copy link
Collaborator

@ddsjoberg ddsjoberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great addition! Thank you!!!

@edelarua edelarua merged commit 01fcc90 into main Aug 20, 2024
35 checks passed
@edelarua edelarua deleted the 283_as_card@main branch August 20, 2024 23:21
@github-actions github-actions bot locked and limited conversation to collaborators Aug 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bind_ard() to return data frames of class 'cards' Add function to coerce data frame to class card
2 participants