summarize_all_qc | R Documentation |
summarize_all_qc
, summarize_at_qc
, and summarize_if_qc
are used exactly the same as dplyr::summarize_all
,
dplyr::summarize_at
, and dplyr::summarize_if
, and require
all of the same arguments and return identical objects. The only difference
is that the _qc
versions print a message indicating the number of NA
or INFinite values created in the new summary variable(s). This is most
useful when using on a grouped data frame.
summarize_all_qc(.tbl, .funs, ..., .group_check = F)
summarise_all_qc(.tbl, .funs, ..., .group_check = F)
summarize_at_qc(.tbl, .vars, .funs, ..., .cols = NULL, .group_check = F)
summarise_at_qc(.tbl, .vars, .funs, ..., .cols = NULL, .group_check = F)
summarize_if_qc(.tbl, .predicate, .funs, ..., .group_check = F)
summarise_if_qc(.tbl, .predicate, .funs, ..., .group_check = F)
.tbl |
A |
.funs |
A function |
... |
Additional arguments for the function calls in
|
.group_check |
a logical value, that when TRUE, will print a table with each group variable and a column called "missing_vars" that lists which variables are missing from the summarized data for each group. Only groups with at least one missing variable are listed. This has no effect on the returned object, and only prints information. Default is FALSE, to avoid excess printing. If data is not grouped and .group_check = T, then an error is thrown. |
.vars |
A list of columns generated by |
.cols |
This argument has been renamed to |
.predicate |
A predicate function to be applied to the columns
or a logical vector. The variables for which |
An object of the same class as .data
. This object will be
identical to that which is returned when running the scoped variants of
dplyr::summarize
.
All functions work with grouped data.
There are _qc
versions of summarize
and summarise
.
But this is America, use a z!
summarise_all
practice_data <-
data.frame(
A = c(1:4, NA),
B = c(NA, 7:10),
C = 21:25,
G = c(1, 1, 1, 2, 2)
)
# Use the _qc versions just like normal dplyr scoped summarize functions.
summarize_at_qc(
practice_data,
vars(A, C),
funs(m = mean(., na.rm = T), s = sum)
)
summarize_all_qc(practice_data, funs(mean))
# Pipes work, just as they always do in dplyr
practice_data %>% summarize_if_qc(is.integer, mean)
# Functions work on grouped data, too
grouped_data <- group_by(practice_data, G)
grouped_data %>%
summarize_at_qc(vars(A, C), funs(m = mean(., na.rm = T), s = sum))
# Setting .group_check = T will print, for each group with a missing value,
# which new variables are missing.
summarize_all_qc(grouped_data, mean, .group_check = T)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.