knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

quickselect

Build Status Build status Codecov test coverage lifecycle

Quickly select columns from a data frame or tibble using regex. It is essentially a wrapper for select(matches("my_var")) from {dyplr} and {tidyselect}. It includes two functions match() and unmatch()

Installation

The development version of quickselect can be installed from GitHub with:

# install.packages("devtools")
devtools::install_github("camkay/quickselect")

Descriptions and Examples

# load quickselect
library(quickselect)
library(dplyr)

# suppress scientific notation
options(scipen = 999)

# create example data
data_example <- data.frame(group  = c("A", "A", "B", "B", "A"),
                           mach   = c(NA, 2, 300, 200, 3),
                           narc   = c(2, 4, 500, 700, 10),
                           psyc   = c(3, 4, 1800, 2000, 5),
                           des    = c(100, 100, 2, 10, 1000),
                           mor    = c(10, 10, 500, 1000, 20))

match

match extracts columns in a data frame that match a specified regex string.

# look at example data
data_example

# match columns that start with m
data_example %>%
  match("^m")

unmatch

unmatch extracts columns in a data frame that DO NOT match a specified regex string.

# look at example data
data_example

# return columns that do not start with m
data_example %>%
  unmatch("^m")


camkay/quickselect documentation built on March 11, 2023, 12:57 a.m.