| filter_qc | R Documentation | 
filter_qc returns an identical object as dplyr::filter, except
that it automatically prints the number of cases (i.e., rows) that do not 
meet the filter conditions and that were thus dropped.
filter_qc(.data, ..., .group_check = F)
.data | 
 A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See Methods, below, for more details.  | 
... | 
 <  | 
.group_check | 
 a logical value, that when TRUE, will print a table with each group variable and columns called "n_rows_dropped" and "percent_dropped" that together indicate, for each group, how many row were dropped when performing filter. Default is FALSE, to avoid excess printing. If data is not grouped and .group_check = T, then an error is thrown.  | 
An object of the same class as .data. This object will be
identical to that which is returned when running the standard 
dplyr::filter function.
There are _qc versions of the scoped filter functions. See 
filter_at_qc, filter_all_qc, or
filter_if_qc.
filter
practice_data <- 
  data.frame(
    A = 1:12, 
    B = 6:17, 
    C = 8:19, 
    G = c(rep(c("A", "B"), each = 6)),
    stringsAsFactors = F
  )
# Basic filtering
filter_qc(practice_data, A > 5)
filter_qc(practice_data, A > 5 & B > 8)
# With grouped data and setting .group_check = T, you can see how many rows
# were dropped per group. Note that this will print a large table if you have 
# a lot of groups.
grouped_data <- group_by(practice_data, G)
filter_qc(grouped_data, A > 3, .group_check = T)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.