Description Usage Arguments See Also Examples
Depivot a dataframe and retrieve unique counts for each column with the option of grouping the counts with a 'grouper' column.
1 2 3 4 5 6 7 | value_count(
data,
names_to = "Variable",
values_to = "Value",
desc = TRUE,
grouper
)
|
data |
A dataframe or tibble. |
names_to |
Passed to 'tidyr::pivot_longer()'. |
values_to |
Passed to 'tidyr::pivot_longer()'. |
desc |
If TRUE, the output is arranged in descending order. Otherwise it is arranged in ascending order. |
grouper |
(Optional) Group by column. |
pivot_longer
reexports
,count
,tidyeval-compat
,arrange
Other summarize functions:
summarize_max()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | library(tidyverse)
test_data <-
tibble(
Group = sample(c("Apple", "Pear"), size = 10, replace = TRUE),
A = sample(c(NA_integer_, 1:3), size = 10, replace = TRUE),
B = sample(c(NA_integer_, 4:6), size = 10, replace = TRUE),
C = sample(c(NA_real_, seq(from = 6.01, to = 6.09, by = 0.01)), size = 10, replace = TRUE)
)
summarize_variables(data = test_data,
incl_num_calc = FALSE)
summarize_variables(data = test_data,
incl_num_calc = TRUE)
summarize_variables(data = test_data,
incl_num_calc = TRUE,
grouper = Group)
summarize_variables(data = test_data,
incl_num_calc = FALSE,
grouper = Group)
observation_count(data = test_data)
value_count(data = test_data)
value_count(data = test_data,
grouper = Group)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.