You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Developers make a decision about which stats are displayed and the rest are lost to the user.
Create separate functions for each combination of stats that the user wants to display (e.g., freq_table_n_percent()).
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:
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)
If you are going to use the same pattern of variables in select repeatedly, then just quickly create a function wrapper.
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:
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:
mtcars %>%
freq_table(am) %>%
select(var, cat, n, percent)
my_freq_table <- function(.data, …) {
.data %>%
freq_table(…) %>%
select(var, cat, n, percent)
}
The text was updated successfully, but these errors were encountered: