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!
You can install the development version of LockeR from GitHub with:
# install.packages("devtools")
devtools::install_github("DHLocke/LockeR")
This package relies heavily on:
- The
tidyverse
packages, namelydplyr
,purrr
,stringr
,tibble
, andggplot2
- The
sf
for spatial data handling andspData
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 anysf
function and parallelizes them, to process large jobs faster over multiple cores.
right now there are five main groups of interrelated functions, in no particular order
-
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!
-
-
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. -
Temperature Conversions: functions including to_cel(), to_farh(), which convert from degrees Fahrenheit to degrees Celsius, and degrees Celsius to degrees Fahrenheit, respectively.
-
Regular Expressions (regex) in Action
-
phone_it_in which standardizes 7 and 10 digit phone numbers with regular expressions, pulled from a stackoverflow answer by Benjamin.
-
text_in_parens which extracts text from within parentheses, which is surprisingly difficult! Taken from this post.
-
str_replace_many like stringr::str_replace_all but accepts many from and to replacements at once, copied from @JosiahParry ’s Gist.
-
-
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И”.
-