excl_neat | R Documentation |
Filters dataset by rows (normally: subjects, observations) and prints the numbers of excluded rows and remaining rows. Returns the filtered dataset and (optionally) also the excluded rows.
excl_neat( dat, filt, excluded = FALSE, group_by = NULL, sort_by = "exclusion", hush = FALSE )
dat |
Data frame to be filtered. |
filt |
An expression to use for filtering, by column values, the
|
excluded |
Logical; |
group_by |
String, or vector of strings: the name(s) of the column(s) in
the |
sort_by |
String; specifies whether the printed counts should be sorted
by exclusion (default; |
hush |
Logical. If |
A data frame with the rows for which the filt
expression is
TRUE
, or, optionally, a list with this data frame plus a data frame
with the excluded rows. At the same time, prints, by default, the count of
remaining and excluded rows.
aggr_neat
data("mtcars") # load base R example dataset # filter mtcars for mpg > 20 excl_neat(mtcars, mpg > 20) # assign the same mtcars_filtered = excl_neat(mtcars, mpg > 20) # (mtcars_filtered now contains the filtered subset) # return and assign excluded rows too mtcars_filtered_plus_excluded = excl_neat(mtcars, mpg > 20, excluded = TRUE) # print filtered data frame print(mtcars_filtered_plus_excluded$filtered) # print data frame with excluded rows print(mtcars_filtered_plus_excluded$excluded) # group printed count by cyl excl_neat(mtcars, mpg > 20, group_by = 'cyl') # sort output by grouping excl_neat(mtcars, mpg > 20, group_by = 'cyl', sort_by = 'group') # group by cyl amd carb excl_neat(mtcars, mpg > 15, group_by = c('cyl', 'carb')) # longer filter expression excl_neat(mtcars, mpg > 15 & gear == 4, group_by = 'cyl',)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.