mutate_all_qc | R Documentation |
mutate_all_qc
, mutate_at_qc
, mutate_if_qc
, and their
transmute
equivalents return identical objects as the scoped versions
of dplyr::mutate
and dplyr::transmute
.The only difference is
that the _qc
versions print a message indicating the number of NA or
INFinite values created in the new or edited variable(s) after calling
mutate
.
mutate_all_qc(.tbl, .funs, ..., .group_check = F)
transmute_all_qc(.tbl, .funs, ..., .group_check = F)
mutate_at_qc(.tbl, .vars, .funs, ..., .cols = NULL, .group_check = F)
transmute_at_qc(.tbl, .vars, .funs, ..., .cols = NULL, .group_check = F)
mutate_if_qc(.tbl, .predicate, .funs, ..., .group_check = F)
transmute_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 columns called "var_name" and "n_missing" that together indicate, for each group, how many values are missing of newly created variables. Only variables that contain at least 1 missing value are reported. 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 mutate_all_qc
,
mutate_at_qc
, mutate_if_qc
, and their transmute
equivalents.
All functions work with grouped data.
summarize_all
practice_data <-
data.frame(
A = c(1:4, NA),
B = c(NA, 7:10),
C = 21:25,
G = c("X", "X", "X", "Y", "Y")
)
# Use the _qc versions just like normal dplyr scoped mutate functions.
mutate_at_qc(
practice_data,
vars(A, C),
funs(m = mean(., na.rm = T), s = sum)
)
mutate_all_qc(practice_data, funs(as.character))
# Pipes work, just as they always do in dplyr
practice_data %>% mutate_if_qc(is.integer, mean)
# Functions work on grouped data, too
grouped_data <- group_by(practice_data, G)
grouped_data %>%
mutate_at_qc(vars(A, C), funs(m = mean(., na.rm = T), s = sum))
# Setting .group_check = T will also print a table indicating which groups
# have a missing value, on what variable, and how many values are missing.
mutate_at_qc(grouped_data, vars(A, B), funs(mean), .group_check = T)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.