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

tbl_summary() update for ordered factors and other class handling #569

Closed
4 tasks
ddsjoberg opened this issue Jul 8, 2020 · 1 comment · Fixed by #794
Closed
4 tasks

tbl_summary() update for ordered factors and other class handling #569

ddsjoberg opened this issue Jul 8, 2020 · 1 comment · Fixed by #794
Milestone

Comments

@ddsjoberg
Copy link
Owner

ddsjoberg commented Jul 8, 2020

tbl_summary() accepts ordered factors, but in a hacky way: we replace the ordered factor with a non-ordered factor.

  # removing ordered class from factor variables -------------------------------
  data <- dplyr::mutate_if(data,
                           ~inherits(., "ordered") && inherits(., "factor"),
                           ~factor(., levels = attr(., "levels"), ordered = FALSE))

The downside to this approach is that the label is stripped from the column, and it's not clean code.

I would eventually like to update so that all data types are accepted, including ordered factors. The following steps would need to be taken.

  • Investigate the location int he code base that erred when ordered factors were passed, and update.
  • Update to accept base R date and datetimes.
  • The current reason we do not accept non-base R classes, is because we don't know how to summarize them.
    • For non-base R classes, should we print an error, and require the user to specify the summary type (continuous, categorical, dichotomous)? Perhaps, for classes that we don't know how to summarize, we can omit them from the table and print a note that we didn't know how to summarize the non-base R class. Then direct them to specify the summary type OR convert to a base R class to have it included in the table.
    • Should we just guess and send the column through the defaulted summary functions? If we do this and there is an error, we should print an informative error message indicating the non-base R class passed, AND the function used to summarize. Ask the user if this class is supported in the summary function.
@ddsjoberg
Copy link
Owner Author

This update will have implications for #488

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant