/LockeR

collection of R functions Dexter Locke uses all of the time

Primary LanguageROtherNOASSERTION

LockeR

LockeR is a safe place to keep miscellaneous functions for reuse.

The purpose of this package is to bundle potentially useful homemade functions currently scattered across the author’s local hard drive in unrelated projects into well-documented code for reuse by others. This is also an opportunity to build package development skills. This package is a work in progress, feedback is welcomed and encouraged!

Installation

You can install the development version of LockeR from GitHub with:

# install.packages("devtools")
devtools::install_github("DHLocke/LockeR")

Dependencies

This package relies heavily on:

  • The tidyverse packages, namely dplyr, purrr, stringr, tibble, and ggplot2
  • The sf for spatial data handling and spData packages spatial data in examples.
  • There are functions for graphing and extracting tables from model objects created by the INLA package.
  • The parallel is used for the st_parallel() function which takes any sf function and parallelizes them, to process large jobs faster over multiple cores.

Families of functions

right now there are five main groups of interrelated functions, in no particular order

  1. Spatial Support: functions including see_sf() and see_spatial() identify sf, and sf, sp, and/or RasterLayer objects in memory, respectively. The st_parallel() parallizes any st_* function in the sf package to take advantage of mutli-core processing for large jobs. This is especially useful for overlay operations like st_intersection.

    • TODO expand to other object types

    • TODO fix get_crs to actually work!

  2. INLA Support: functions including get_inla(), inla_plot_fe(), and inla_table_fe() for accessing and prying information out of objects created by the INLA package. INLA (Integrated Nested Laplace Approximation) is an method for approximate Bayesian inference. It uses calculus instead of Markov Chain Monte Carlo methods. The resultant model objects are densely-packed list objects, and these functions make handling and extracting summaries more user-friendly.

  3. Temperature Conversions: functions including to_cel(), to_farh(), which convert from degrees Fahrenheit to degrees Celsius, and degrees Celsius to degrees Fahrenheit, respectively.

  4. Regular Expressions (regex) in Action

  5. Potpourri (strange since the package is already a bag of miscellany):

    • set_up_dirs() makes commonly-used folders to expedite project set up, and create standardization across projects. This makes it easier to re-use snippets of code from other projects to save out tables and figures.

    • logit() and inv_logit() which takes logit and the inverse logit of proportions, copied from the boot package.

    • nin which is a ‘not in’ opperator, the complement to %in%, and like dplyr::anti_join but for vectors instead of data frame columns. This is affectionately also known as the Trent Rezonr function, in honor of the front man of the industrial rock band Nine Inch Nails, often abbreviated as “NIИ”.