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 select stats to vignette #15

Open
mbcann01 opened this issue Dec 20, 2019 · 0 comments
Open

Add select stats to vignette #15

mbcann01 opened this issue Dec 20, 2019 · 0 comments

Comments

@mbcann01
Copy link
Member

mbcann01 commented Dec 20, 2019

In #13 we changed the output of freq_table to include all stats. We recognize that many users will often not need/want all of these statistics, but restricting display of some of the statistics would require one of the following two options:

  1. Developers make a decision about which stats are displayed and the rest are lost to the user.
  2. Create separate functions for each combination of stats that the user wants to display (e.g., freq_table_n_percent()).
  3. Add arguments to the freq_table function that allow the user to select which stats are displayed.

Option 1 is too restrictive.
Option 2 is unwieldy and contradicts the intent of freq_table, which is to be simple and easy to remember/use.
Option 3 was the original solution, but it felt kind of clunky and it still required the developers to make choices up front about options for which combinations of statistics the users could choose to display (e.g., stats = “n and percent”). Further, we are trying to adhere to the philosophy that the function should do one specific thing. This function creates a table of statistics. The dplyr::select() function makes it really straight forward to choose which of those statistics to keep.

Therefore, when the user does not wish to display all of the statistics that freq_table outputs by default we recommend one of the following two solutions:

  1. Just use select. After all, freq_table was made to be used in a dplyr pipeline.

mtcars %>%
freq_table(am) %>%
select(var, cat, n, percent)

  1. If you are going to use the same pattern of variables in select repeatedly, then just quickly create a function wrapper.

my_freq_table <- function(.data, …) {
.data %>%
freq_table(…) %>%
select(var, cat, n, percent)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Develop Next
Development

No branches or pull requests

1 participant