Learn R Programming

quickcode is a collection of small, dependable helpers for everyday R scripting: a full family of not.* validation functions, PHP-style array/data-frame operations (push, pop, shuffle, rep), nullish-coalescing and "not in" operators, outlier and distribution detection, super variables, function-usage tracking, RStudio snippet addins, and more. None of it is flashy — it just removes boilerplate you'd otherwise rewrite in every project.

Installation

Install the released version from CRAN:

install.packages("quickcode")

Or install the development version from GitHub:

# install.packages("devtools")
devtools::install_github("oobianom/quickcode")

Load it like any other package:

library(quickcode)

Why quickcode

  • Consistent negations. is.null() has no built-in opposite. quickcode adds not.null(), not.na(), not.numeric(), not.integer(), not.logical(), not.vector(), not.data(), not.environment(), not.duplicated(), not.image(), not.inherits(), not.exists() and friends, so conditionals read the way you'd say them out loud.
  • PHP-style array ergonomics. vector_push(), vector_pop(), data_push(), data_pop(), list_push(), data_shuffle(), data_rep() bring the array functions many scripters miss from other languages, working across vectors, lists, and data frames.
  • Operators that save keystrokes. %nin% (not in), %or% (nullish coalescing), %eo% (error coalescing), and %match% (string similarity) shorten common conditional patterns.
  • One-call environment resets. refresh() / clean() clear the console, clear the environment, reset the working directory, and reload files/libraries in a single call.
  • Statistics and outlier helpers. Z-scores, IQR-based and grouped outlier detection, distribution fit-checking (is.normal, is.poisson, is.weibull, ...), geometric mean/SD/CV, and histogram comparisons.
  • Super variables. newSuperVar() creates a variable that is accessible and mutable from any scope, with optional locking, class enforcement, and a limited number of permitted edits.
  • RStudio addins. Insert header comments, section dividers, or environment-reset snippets straight from the RStudio Addins menu — no need to remember or retype boilerplate.
  • Function usage tracking. track_func() wraps functions to record call frequency, timing, and argument patterns, for lightweight profiling and usage analytics.

Quick examples

The not.* family

not.null(NULL)      # TRUE
not.na(NA)           # FALSE
not.integer(45L)     # FALSE
not.integer(45)      # TRUE

Nullish coalescing and "not in"

NULL %or% "default"        # "default"
NA %or% "default"          # "default"
5 %or% "default"           # 5

5 %nin% c(1:10)            # FALSE
5 %nin% c(11:20)           # TRUE

PHP-style vector and data frame helpers

p1 <- c(6, 7, 8)
p2 <- c(1, 2, 3)
vector_push(p1, p2)
p1
#> [1] 6 7 8 1 2 3

df1 <- data.frame(ID = 1:10, ID2 = 1:10)
df2 <- data.frame(ID = 11:20, ID2 = 21:30)
data_push(df1, df2, "rows")

One-line variable initialization

init(a, b, c)               # a, b, c set to NULL
init(x, y, z, value = 5)    # x, y, z set to 5

Environment reset

quickcode::refresh()

quickcode::clean(
  setwd  = "/path/to/project",
  source = c("file1.R", "file2.R"),
  load   = c("data.RData")
)

Super variables

newSuperVar(config, value = list(threshold = 10), lock = TRUE)
config                 # view current value
config.set(list(threshold = 20))  # blocked while locked

Outlier and distribution checks

x <- c(rnorm(100), 50)
detect_outlier2(x)
zscore(x)
is.normal(rnorm(100))

See vignette("quickcode_r_introduction") for a longer walkthrough.

Function reference

NOT / validation functions

FunctionDescription
not.nullNot NULL
not.naNot NA
not.empty / is.emptyNot empty / is empty
not.numericNot numeric
not.integerNot an integer
not.logicalNot logical
not.vectorNot a vector
not.dataNot a data object
not.duplicatedNot duplicated elements
not.environmentNot an environment
not.image / is.imageFile extension is/isn't an image
not.inheritsDoes not inherit from specified classes
not.existsObject does not exist
has.errorCheck if a call or expression produces an error

Operators

OperatorDescription
%nin% (alias %!in%)Not in vector or array
%or%Nullish coalescing operator
%eo%Error coalescing operator
%match%Percentage string similarity match
%.%Simple function chaining

PHP-style array / data operations

FunctionDescription
vector_push / vector_popAdd / remove elements from a vector
list_pushAdd elements to a list
data_push / data_popAdd / remove rows or columns from a data frame
data_pop_filterRemove elements from data matching a filter
data_rep / rows.rep / cols.repDuplicate rows or columns X times
data_shuffle / list_shuffle / vector_shuffleShuffle a data frame, list, or vector
switch_rows / switch_colsSwap two rows or columns
sample_by_columnRe-sample a dataset by column
mutate_filterMutate only a subset of a dataset
add_key (alias indexed)Add index keys to a vector, list, data frame, or matrix

Variables & environment

FunctionDescription
initInitialize one or more variables/objects at once
newSuperVarCreate a variable accessible/mutable from any scope, with locking and edit limits
setOnceSet a variable only once
refresh / clean / libraryAllClear environment/console, reset working directory, load files & libraries
summarize.envobjSummarize environment objects and their sizes
lastwdReturn to the previous working directory

Statistics, outliers & distributions

FunctionDescription
zscore / zscore_outlier / zscore_outlier2Z-score calculation and z-score-based outlier flagging
detect_outlier / detect_outlier2 / iqr_outlierOutlier detection (including grouped)
is.normal, is.lognormal, is.uniform, is.poisson, is.gamma, is.weibull, is.cauchy, is.logisticTest whether data fits a given distribution
getDistributionFit-check data against a distribution
geo.mean, geo.sd, geo.cvGeometric mean, standard deviation, coefficient of variation
mode.calcMode of a numeric or character vector
na.cumsumCumulative sum with NA removal
normalize.vectorNormalize a numeric vector to [0, 1]
sub.range / in.rangeRange difference / range membership checks
unique_lenCombine unique() and length()
pairDistDistance of points from a cluster center
compHistCompare histograms of two distributions

Machine learning & modeling utilities

FunctionDescription
cat_to_num / cat_to_num2Convert categorical values to numeric
from_tensor_slicesCreate tensor-like slices from a data frame or matrix
multihead_attMulti-head attention computation
learn_rate_schedulerLearning rate scheduling utilities
make_dosing_dfCreate subject-by-time dosing records with covariates

Strings & text

FunctionDescription
bionic_txtGenerate bionic-reading formatted text
randStringGenerate a random string
strsplit.bool / strsplit.numSplit a string into a boolean / numeric vector
percent_matchPercentage match between two strings
ndecimalCount decimal places in a number
as.boolean / yesNoBoolConvert between boolean representations
extract_comment / remove_comment / remove_content_in_quotesText/comment extraction and cleanup
getDateExtract all dates from a string
extract_IPExtract IP addresses from a string

Dates

FunctionDescription
date1to3 / date3to1Combine vectors into a Date, or split a Date into vectors
getWeekSeqConvert dates into numeric week counts
is.leapCheck whether a year is a leap year
fAddDateAppend a date to a filename
is.increasing / is.decreasingCheck whether values in a vector are increasing/decreasing

Files & filesystem

FunctionDescription
duplicateDuplicate a file with global text replacement
ai.duplicatePrompt-guided duplication and editing of files
trim.fileRemove empty lines from a file
sort_file_type / sort_lengthSort a vector by file type or content length
read.csv.print / read.table.printRead and preview the first X rows/columns of a file
insertInTextInsert a string into the current RStudio file (Shiny helper)

RStudio addins & snippets

Addin / functionDescription
add.headerAdd a header comment to the current R file
header.rmdAdd a header comment to the current Rmd file
add.sect.commentInsert a custom section comment
add.snippet.clearInsert a console-clear / set-directory snippet

Colors & shapes

FunctionDescription
rcolorconstNamed R color constants
mix.color / mix.cols.btwBlend two or more colors
setDisAlpha / unsetDisAlphaSet/unset color transparency
create_shapeCreate geometric shapes with optional text

Package & repo utilities

FunctionDescription
find_packagesSearch CRAN packages by keyword
archivedPkgList all CRAN-archived R packages
rDecomPkgCheck whether a package has been decommissioned from CRAN
getGitRepoStart / getGitRepoChangeFetch a GitHub repo's creation / last-updated date
track_funcTrack function call frequency, timing, and usage patterns

Math & misc

FunctionDescription
plus / minus / incIncrement or decrement a vector by a value
numberGenerate random integers
constCommon mathematical constants
math.mm / math.qtMiscellaneous math and confidence-interval computations
error.out (%eo%)Return an alternative value if an expression errors
or (%or%)Return an alternative value if an expression is empty/NA/NULL
chain_sep (%.%) / chain_funcSimple function chaining

This list covers the most commonly used functions; run library(help = "quickcode") or browse the man/ directory for the complete, authoritative reference with full argument details and runnable examples.

Vignettes

  • vignette("quickcode_r_introduction") — general tour of the package
  • vignette("add_today_date_to_filenames_quickcode") — appending dates to filenames with fAddDate()
  • vignette("nullish_coalescing_operator_r") — using %or% and %eo%
  • vignette("track_function_usage_r") — profiling function usage with track_func()

Getting help

Authors

License

MIT © Obinna Obianom. See LICENSE for details.

Copy Link

Version

Install

install.packages('quickcode')

Monthly Downloads

519

Version

1.2.0

License

MIT + file LICENSE

Maintainer

Obinna Obianom

Last Published

August 26th, 2026

Functions in quickcode (1.2.0)

data_shuffle

Shuffle a data frame just like shuffle in PHP
data_rep

Duplicate a data rows or columns X times
is.increasing

Check is numbers in a vector are decreasing or increasing
date3to1

Combine vector to create Date, or split Date into vector
geo.cv

Calculate geometric coefficient of variation, mean, or SD and round
fAddDate

Append date to filename
error.out

Error coalescing operator
getDate

Extract all dates from a string
lastwd

Go back to previous directory
learn_rate_scheduler

Learning Rate Scheduler
inc

Increment vector by value
init

Initialize new variables and objects
%nin%

Not in vector or array
newSuperVar

Create and use a super variable with unique capabilities
detect_outlier2

Advanced Outlier Detection in Numeric Data with Optional Grouping
is.lognormal

Check if a data fits the distribution
libraryAll

Load specific R libraries and clear environment
duplicate

Duplicate a file with global text replacement
find_packages

Fetch R package based on keyword
header.rmd

Snippet function to add header to a current Rmd opened file
getWeekSeq

Convert Dates into Numeric Week Counts
in.range

If number falls within a range of values and get closest values
not.empty

Not empty
from_tensor_slices

Create Tensor-Like Slices from a Data Frame or Matrix
multihead_att

Multi-Head Attention
getGitRepoStart

Fetch GitHub Repository Creation & Last Updated Date
list_shuffle

Shuffle a list object just like shuffle in PHP
mutate_filter

Mutate only a subset of dataset intact
not.environment

Not an environment
not.data

Not a data
make_dosing_df

Create Subject-by-Time Dosing Records (Base R) with Optional Subject-Level Covariates
mix.cols.btw

Mix or Blend colors between two or more colors
math.qt

Miscellaneous math computations: Corresponding m-m and quantile for confident intervals
mode.calc

Calculate the Mode of a Numeric or Character Vector
has.error

Check if a call or expression produces errors
not.duplicated

Not duplicated elements
not.integer

Not an integer
pairDist

Calculate the distance of points from the center of a cluster
minus

Decrease vector by value
na.cumsum

Cumulative Sum with NA Removal
list_push

Add elements to a list like array_push in PHP
detect_outlier

Detect Outliers in a Numeric Vector
not.exists

Not exists
percent_match

Function to calculate the percentage of matching between two strings
not.na

Not NA
insertInText

Shiny app function to insert string to current file in RStudio
nonmem_scaling

Compute S1 scaling expression for NONMEM
normalize.vector

Normalize a Numeric Vector to the Range [0, 1]
is.image

Is file name extension(s) an image
not.logical

Not logical
%.%

simple function chaining routine
chain_func

Combine specific functions as store as one function
setOnce

Set a variable only once
mix.color

Mix or Blend two or more colors
number

Generate a random number (integer)
ndecimal

Count the number of decimal places
not.numeric

Not numeric
or

Nullish coalescing operator
rDecomPkg

Check whether an R package has been decommissioned in CRAN
randString

Generate a random string
not.image

File name extension(s) is Not an image
not.inherits

Not inherit from any of the classes specified
plus

Increment vector by value
rows.rep

Replicate Rows in a Data Frame
summarize.envobj

Get all the environment objects and their sizes
sub.range

Calculate the Range Difference of a Numeric Vector
not.null

Not NULL
switch_cols

Switch the index of two columns in a data set
refresh

Clear environment, clear console, set work directory and load files
read.table.print

Read in a table and show first X rows and columns
sort_length

Sort vector by length or file types of its content
unique_len

Combine unique() and length()
not.vector

Not a vector
vector_pop

Remove last n elements or specified elements from a vector like array_pop in PHP
switch_rows

Switch the index of two rows in a data set
vector_shuffle

Shuffle a vector just like shuffle in PHP
vector_push

Add elements to a vector like array_push in PHP
sample_by_column

Re-sample a dataset by column and return number of entry needed
yesNoBool

Convert Yes/No to Binary or Logical
strsplit.bool

Split a string of values and return as boolean vector
strsplit.num

Split a string of numbers and return as numeric vector
rcolorconst

R Color Constant
zscore

Calculates Z-Scores of a distribution
read.csv.print

Read a CSV and preview first X rows and columns
track_func

Track Function Usage and Performance
print.nonmem_scaling

Print method for s1_scaling objects
trim.file

Remove Empty Lines from a File
ai.duplicate

Prompt guided duplication and editing of files
cat_to_num

Convert Categorical Values to Numeric Improvement to seq_along()
bionic_txt

Generate a bionic text
archivedPkg

Listing of all CRAN archived R packages
clean

Clear environment, clear console, set work directory and load files
add.header

Addin snippet function to add header comment to a current opened file
add.sect.comment

Addin snippet function to custom section comment
add.snippet.clear

Snippet R function to clear console and set directory
as.boolean

Convert boolean values between formats
add_key

Add index keys to a vector or data frame or list or matrix
data_pop

Remove last n rows or column or specified elements from a data frame like array_pop in PHP
const

Mathematical constants
cols.rep

Replicate Columns in a Data Frame
extract_IP

Extract all IP addresses from a string
extract_comment

Extract all comments or functions from a file
create_shape

Create geometric shapes with optional text
compHist

Compare histograms of two distributions
data_push

Add data to another data like array_push in PHP
data_pop_filter

Remove elements from a data matching filter