supportR
is an R package where the only unifying theme of the functions is honestly just that I wrote them. That said, there are some useful functions for data wrangling and plotting in particular, though functions for other purposes are also included. I’ll add functions to this package as I write more orphan scripts that I hope others might find useful so stay tuned!
Installation
You can install the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("njlyon0/supportR")
Data Wrangling
summary_table
: Calculates summary values (mean, standard deviation, sample size, and standard error) of a given response variable within supplied groupssafe_rename
: Renames columns in a given dataframe by matching ‘bad’ names with ‘good’ namesname_vec
: Creates a named vector of specified contents and names. Useful when creating named vectors that are too long to create manually or when creating the vector and then naming it is cumbersomecrop_tri
: Removes the specified “triangle” (either upper or lower) of a symmetric data object by replacing with NAs. Also allows user to specify whether to keep or also drop the diagonalarray_melt
: “Flattens” an array of dimensions X, Y, and Z into a dataframe containing columnsx
,y
,z
, andvalue
wherevalue
is whatever was stored in the array at those coordinates
Quality Control (QC)
diff_check
: Compares two vectors and identifies what elements are found in the first but not the second (i.e., lost components) and what elements are found in the second but not the first (i.e., gained components). Extremely useful prior tojoin
ing two dataframes to compare index column contents or to ensure no columns are unexpectedly lost during complex wrangling operationsnum_check
: Checks column(s) that should contain only numeric values for any entries that would be coerced to NA ifas.numeric
is runcount
: Counts instances of each unique element in a provided vectorreplace_non_ascii
: Replaces non-ASCII characters with visually comparable ASCII equivalentsdate_check
: Checks column(s) that should contain only date values for any entries that would be coerced to NA ifas.Date
is rundate_format_guess
: Checks a column containing multiple ambiguous date formats and identifies its best guess for the format each date is in (e.g., ‘dd/mm/yyyy’ versus ‘yyyy/dd/mm’, etc.)
Visualization & Graphics
theme_lyon
: Applies a set of modifications to the non-data aspects of aggplot2
plot to ensure a consistent “feel” of a set of plotsordination
: Creates an ordination for either the nonmetric multidimensional scaling (NMS) dissimilarity matrix created byvegan::metaMDS
or for the principal coordinates analysis (PCoA) distance matrix returned byape::pcoa
Operations Outside of R
github_ls
: Lists contents of a GitHub repository from its URL and returns a simple dataframe containing the name, type, and file path of identified objects. Supports recursive listing (i.e., listing of contents of subfolders identified in first list of contents)github_tree
: Creates a file tree diagram of a GitHub repository from its URLtabularize_md
: Converts a markdown file into a table that retains the nested structure of any headings in the file. Accepts either the file name/path locally or a URL connection to a markdown file hosted online (e.g., a GitHub repository README.md, etc.)rmd_export
: Allows knitting of a specified R Markdown file locally and simultaneously to a specified Google Drive folder. NOTE: you must authorize R to work with Google Drive by usinggoogldrive::drive_auth()
for this function to work
Looking Ahead
More functions are likely to be developed and housed within this package so stay tuned! Feel free to post ideas for new functions as an issue on this repository and I’ll do my best to build them!