sum_tab | R Documentation |
sum_tab
takes a built in function (table) and turns it into something
that can be integrated into a sequence of pipes. As with sum_lm
,
this is useful for when you want to see many tables at once,
or put a few tables into a bigger table.
Writing this was surprisingly complicated – it uses enquo() to capture
the unquoted variable name and !! to unquote it within the function.
sum_tab(data, var_name)
data |
A data frame or tibble. |
var_name |
The name of the variable/column to generate the frequency table. |
A table showing the frequency of each unique value in the specified variable. #'
# simple example: entire dataset
PaluckMetaSOP::sv_data |> sum_tab(behavior_type)
## Not run:
# example with split and apply to many subsets
library(purrr)
PaluckMetaSOP::sv_data |> split(~study_design) |>
map(~ sum_tab(., behavior_type)) |> bind_rows(.id = "study_design")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.