-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
54 lines (43 loc) · 1.28 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# `countess`: Helpers for `dplyr`'s `count()` Function
Convenience functions built on top of dplyr to count the number of instances of
each value in columns of data frames.
- `count_all()` is `group_by_all()` plus `tally()`.
- `count_at()` is `group_by_at()` plus `tally()`.
- `count_if()` is `group_by_if()` plus `tally()`.
## Installation
You can install this development version of countess using
``` r
# install.packages("remotes")
remotes::install_github("richierocks/countess")
```
## Example
This is a basic example which shows you how to solve a common problem:
```{r loadplyr, echo = FALSE}
suppressPackageStartupMessages(library(dplyr))
set.seed(19790801)
```
```{r counts}
library(dplyr)
library(countess)
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)
```