Learn R Programming

⚠️There's a newer version (0.2.6) of this package.Take me there.

poorman

I’d seen my father. He was a poor man, and I watched him do astonishing things. - Sidney Poitier

Overview

poorman is a grammar of data manipulation, providing dependency free versions of dplyr verbs that help you solve the most common data manipulation challenges:

  • select() picks variables based on their names.
  • mutate() adds new variables that are functions of existing variables.
  • filter() picks cases based on their values.
  • summarise() reduces multiple values down to a single summary.
  • arrange() changes the ordering of the rows.

poorman attempts to replicate the dplyr API exactly such that your dplyr code will still run even if you use poorman in its place. In addition to replicating dplyr functionality, poorman implements other functionality from the wider tidyverse such as select helpers and the pipe, %>%.

For more details on the functionality available within poorman, check out the poorman series of blog posts here.

Installation

You can install the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("nathaneastwood/poorman")

Or you can install the latest release from CRAN with:

install.packages("poorman")

Docker

If you’d like to try out the package using Docker, you can run the latest image with:

docker run --rm -it nathaneastwood/poorman

Usage

library(poorman, warn.conflicts = FALSE)
# 
#   I'd seen my father. He was a poor man, and I watched him do astonishing things.
#     - Sidney Poitier

mtcars %>%
  select(mpg, starts_with("c")) %>%
  mutate(mpg2 = mpg * 2, mpg4 = mpg2 * 2) %>%
  filter(mpg > 28)
#                 mpg cyl carb mpg2  mpg4
# Fiat 128       32.4   4    1 64.8 129.6
# Honda Civic    30.4   4    2 60.8 121.6
# Toyota Corolla 33.9   4    1 67.8 135.6
# Lotus Europa   30.4   4    2 60.8 121.6

mtcars %>%
  group_by(am, cyl) %>%
  summarise(meanMpg = mean(mpg), sumMpg = sum(mpg)) %>%
  ungroup()
#   am cyl  meanMpg sumMpg
# 1  0   4 22.90000   68.7
# 2  0   6 19.12500   76.5
# 3  0   8 15.05000  180.6
# 4  1   4 28.07500  224.6
# 5  1   6 20.56667   61.7
# 6  1   8 15.40000   30.8

Related Work

  • dplyr
  • bplyr - imports magrittr and rlang; it prepends functions with b_*(), e.g. b_select().
  • tbltools - imports magrittr and appends *_data() to each of its functions, e.g. select_data().

Copy Link

Version

Install

install.packages('poorman')

Monthly Downloads

8,326

Version

0.2.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Nathan Eastwood

Last Published

May 10th, 2020

Functions in poorman (0.2.0)

select_helpers

Select Helpers
desc

Descending order
between

Do values in a numeric vector fall in specified range?
lag

Compute lagged or leading values
mutate

Create or transform variables
rownames

Tools for working with row names
slice

Choose rows by position
print.grouped_data

Print a grouped data.frame
poorman

poorman: A Poor Man's Base R Copy of 'dplyr' Verbs
get_groups

Return grouping variables
relocate

Select/relocate variables by name
groups

Group by one or more variables
n

The number of observations in the current group
n_distinct

Count the number of unique values in a set of vectors
summarise

Reduce multiple values down to a single value
window_rank

Windowed Rank Functions
pipe

Forward-pipe operator
filter_joins

Filtering joins filter rows from x based on the presence or absence of matches in y:
filter

Return rows with matching conditions
peek_vars

Peek at variables in the selection context
if_else

Vectorised if
joins

Join two data.frames together
arrange

Arrange rows by variables
count

Count observations by group
pull

Pull out a single variable
rename

Rename columns