A package of general purpose functions that might save time or help tidy up code.
Some of these functions are similar to existing functions but are simpler to use
or have more features (e.g, timeit and loop.tracker reduce an initialisation,
'during' and close three-line call structure, to a single function call.
Also, some of these functions are useful for building packages and pipelines,
for instance: Header(), to provide strong visual deliniation between
procedures in console output, by an ascii bordered heading; loop.tracker()
to track the progress of loops (called with only 1 line of code), with the
option to periodically backup a key object during the loop; estimate.memory()
to determine whether the object may exceed some threshold before creating it,
timeit(), a one line wrapper for proftools which gives a detailed breakdown of
time taken, and time within each function called during a procedure; and
check.linux.install() to verify installation status of terminal commands before
using system(), top() to examine current memory and CPU usage [using the system
'top' command]. prv() is useful for debugging as it allows a detailed preview of
objects, and is as easy as placing print statements within loops/functions but
gives more information, and gives compact output for large objects. For testing
sim.cor() provides a simple way to simulate a correlated data matrix, as often
this is more realistic than completely random data. Otherwise summarise.r.datasets
gives a list of all available datasets and their structure and dimensionality.
- check.linux.install
Check whether a given system command is installed (e.g, bash)
- comma.list
Nicely format output lists with comma separation and length control
- comify
Function to add commas for large numbers
- cor.with
simulate a variable with a specified correlation to an existing variable
- Dim
same as dim() function but works for more objects, including vectors
- dup.pairs
Obtain an ordered index of all instances of values with duplicates
- estimate.memory
Estimate the memory required for an object
- exists.not.function
same as exists() function but ignores functions
- extend.pc
Extend an interval by percentage
- fakeLines
Create randomized lines of text for testing
- force.percentage
Force argument to be a decimal percentage
- force.scalar
Force argument to be a scalar
- get.distinct.cols
Return up to 22 distinct colours
- getRepositories
Return list of available repositories
- has.method
Determine whether a function can be applied to an S4 class/object
- headl
A good way to preview large lists
- Header
Print heading text with a border
- is.vec.logical
Test whether vector is logical independent of type
- is.vec.numeric
Test whether vector is numeric independent of type
- list.functions.in.file
Show all functions used in an R script file, by package
- list.to.env
Inserts new variables in current environment from a named list
- loess.scatter
Draw a scatterplot with a fit line
- loop.tracker
Creates a progess bar within a loop with only 1 line
- Mode
Find the mode(s) of a vector
- must.use.package
Do everything possible to load an R package
- narm
Return an object with missing values removed
- nearest.to
Similar to base match function but picks nearest instead of exact match
- Numerify
Convert only suitable columns to numeric format in data.frame
- out.of
Simplify outputting fractions/percentages
- p.to.Z
Convert p-values to Z-scores
- packages.loaded
quietly test whether packages are loaded without using require
- pad.left
Print a vector with appropriate padding so each has equal char length
- pctile
Find data thresholds corresponding to percentiles
- ppa
Posterior probability for p-values
- preview
same as prv, but enter arguments as strings
- prv.large
tidy representation for large matrices/data.frames
- prv
compact preview of objects (more complete than 'print')
- replace.missing.df
replace missing values in data.frame automatically
- Rfile.index
Create an index file for an R function file
- rmv.names
Remove names from object
- rmv.spc
Remove leading and trailing spaces (or other character)
- search.cran
Search all CRAN packages for those containing keyword(s)
- sim.cor
simulate a correlated dataset
- simple.date
generate a string with compact summary of date/time
- spc
Print a character a specified number of times
- standardize
Convert a numeric vector to Z-scores
- Substitute
multivariable version of substitute (base)
- summary2
Extension of base:summary that adds SD, SE and keeps names fixed and cleaner
- summarise.r.datasets
show and summarise all available example datasets
- table2d
Extension of base:table that forces fixed rows and columns
- textogram
Make an ascii histogram in the console
- timeit
Times an expression, with breakdown of time spent in functions
- toheader
Return a string with each first letter of each word in upper case
- top
report on CPU and memory usage, overall or by process
- Unlist
Unlist a list, starting only from a set depth
- wait
Wait for a period of time
- which.outlier
Return indexes of univariate outliers
- Z.to.p
Convert Z-scores to p-values