summarize_qc | R Documentation |
summarize_qc
is used exactly the same as dplyr::summarize
and
requires all of the same arguments and returns an identical object. The only
difference is that summarize_qc
prints 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_qc(.data = NULL, ..., .group_check = F)
summarise_qc(.data = NULL, ..., .group_check = F)
An object of the same class as .data
. This object will be
identical to that which is returned when running dplyr::summarise
.
There are _qc
versions of the scoped summarize functions. See
summarize_at_qc
, summarize_all_qc
, or
summarize_if_qc
.
All functions work with grouped data.
There are _qc
versions of summarize
and summarise
.
But this is America, use a z!
summarise
practice_data <-
data.frame(
A = c(1:4, NA),
B = c(NA, 7:10),
C = 21:25,
G = c("X", "X", "X", "Y", "Y"),
stringsAsFactors = F
)
summarize_qc(practice_data, new_var_1 = mean(C), sum(A))
summarize_qc(practice_data, new_var_1 = mean(C), sum(A, na.rm = T))
# Pipes work
practice_data %>%
summarize_qc(practice_data, new_var_1 = mean(C), sum(A, na.rm = T))
# Functions worked on grouped data, too
grouped_data <- dplyr::group_by(practice_data, G)
summarize_qc(grouped_data, new_var_1 = mean(A), mean_b = mean(B), sum(C))
# Setting .group_check = T will print, for each group with a missing value,
which new variables are missing.
summarize_qc(
grouped_data,
.group_check = T,
new_var_1 = mean(A),
mean_b = mean(B),
sum(C)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.