Description Usage Arguments Value See Also Examples
Variants of dplyr
's count
function, letting you
count the instances of each value in columns of your data frame.
count_all
group_by_all + tally
count_at
group_by_at + tally
count_if
group_by_if + tally
1 2 3 4 5 |
x |
A |
wt |
(Optional) If omitted (and no variable named n exists in the data),
will count the number of rows. If specified, will perform a "weighted" tally
by summing the (non-missing) values of variable wt. A column named n (but
not nn or nnn) will be used as weighting variable by default in tally(), but
not in count(). This argument is automatically quoted and later evaluated in
the context of the data frame. It supports unquoting. Passed to
|
sort |
Logical. Should the results be sorted by decreasing |
.vars |
A list of columns generated by vars(), a character vector of
column names, a numeric vector of column positions, or NULL. Passed to
|
.predicate |
A predicate function to be applied to the columns or a
logical vector. The variables for which |
A summarized version of x
.
count
and group_by_all
1 2 3 4 5 6 7 8 9 10 | library(dplyr)
n <- 100
quarks <- data_frame(
first_gen = sample(c("up", "down"), n, replace = TRUE),
second_gen = sample(c("charm", "strange"), n, replace = TRUE),
third_gen = factor(sample(c("top", "bottom"), n, replace = TRUE))
)
quarks %>% count_all()
quarks %>% count_at(vars(contains("ir")))
quarks %>% count_if(is.factor)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.