Skip to content

m-clark/tidyext

Repository files navigation

R build status codecov


tidyext

Overview

Extensions and extras for tidy processing. This package provides some data processing and summarizing functions that would commonly be useful in the tidyverse. For folks that do a lot of data processing in that world, these make a handful of some very common tasks a bit easier, and with an eye toward eventual tidy/clean presentation and visualization with tools like kableExtra and ggplot2.

As these functions are more universally useful, especially to my colleagues and friends who use R, putting them as their own package with few dependencies will perhaps make it easier to use for them. The goal is more or less for this to depend on nothing one wouldn’t have already with base R and the tidyverse package loaded. Also, as all the functions use the tidyverse functionality, they are easily customizable.

Installation

To install from GitHub the devtools package is required.

devtools::install_github('m-clark/tidyext')

Note that this package more or less assumes your are working within the tidyverse, especially dplyr. As such you should have the tidyverse packages installed.

Functions

  • cat_by: A quick summarize for categorical variables, possibly with dplyr::group_by, that provides frequencies and percentages of categories, ready for publishing tables or plotting.

  • combn_2_col: Takes a column with multiple entries per cell and creates indicator columns of all possible combinations of the cell values up to m combinations.

  • create_prediction_data: Straightforward way to quickly create data to make model predictions.

  • describe_all: A summary function for mixed data types that provides the information I usually want. Saves one from doing a group_by %>% summarize operation to create multiple results for multiple types of variables. Has corresponding describe_all_num and describe_all_cat for numeric-only and categorical-only data respectively.

  • num_by: A quick summarize, possibly with dplyr::group_by, that provides things like mean, sd, etc. See num_summary.

  • num_summary: A little better than the base R summary, gives the info one typically wants as well as options for rounding and other statistics.

  • onehot: A function for one-hot encoding with a few helpful options for dealing with missing data, using sparse matrices, and more.

  • pre_process: Easily pre-process a data set with common operations like standardization, logging, etc.

  • sum_NA, sum_NaN, sum_blank: Understand your nothingness.

  • row_sums, row_means, row_apply: Simple (intuitive) rowwise calculations.


Version history

  • 0.3.0 add row_sums, row_means, row_apply
  • 0.2.x Misc updates
  • 0.2.0 Website
  • 0.1.3 Added gather_multi
  • 0.1.2 Added spread2
  • 0.1.1 Added pre_process
  • 0.1.0 Initial release