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 latest version of the package on CRAN 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

6,277

Version

0.2.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Nathan Eastwood

Last Published

July 1st, 2020

Functions in poorman (0.2.1)

between

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

Context dependent expressions
rename

Rename columns
lag

Compute lagged or leading values
joins

Join two data.frames together
recode

Recode values
filter

Return rows with matching conditions
filter_joins

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

Get a glimpse of your data
where

Select variables with a function
group_by

Group by one or more variables
mutate

Create or transform variables
na_if

Convert values to NA
group_metadata

Grouping metadata
slice

Subset rows by position
summarise

Reduce multiple values down to a single value
count

Count observations by group
window_rank

Windowed Rank Functions
n_distinct

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

Split data.frame by groups
desc

Descending order
if_else

Vectorised if
poorman

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

Pull out a single variable
replace_na

Replace missing values
rownames

Tools for working with row names
peek_vars

Peek at variables in the selection context
near

Compare two numeric vectors
relocate

Select/relocate variables by name
select_helpers

Select Helpers
pipe

Forward-pipe operator
coalesce

Find first non-missing element
arrange

Arrange rows by variables
distinct

Subset distinct/unique rows