Skip to content
/ jspr Public

A personal package containing useful functions used on a daily basis.

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

jamespyon/jspr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

178 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jspr (Pronounced ˈja-spər or ˈdʒæspə)

Introduction

What is the definition of jasper?

The following is a “long and boring” definition of the word jasper from ChatGPT:

Jasper is a cryptocrystalline variety of quartz characterized by its opaque appearance and intricate patterns, commonly exhibiting hues ranging from red and brown to yellow and green. Its formation occurs through the slow crystallization of silica-rich fluids within sedimentary rocks or volcanic deposits, a process that typically spans extended geological timescales.

Geologically, jasper is classified as a microcrystalline quartz, distinguished by its dense, fine-grained structure which contributes to its durability and polishability. This mineral’s historical significance stems from its enduring use in decorative arts and jewelry across civilizations, owing to its aesthetic appeal and cultural symbolism.

Metaphysically, jasper holds significance in esoteric practices, believed to impart qualities of stability, grounding, and endurance. Different varieties of jasper are purported to exhibit distinct energetic properties, influencing its application in spiritual and holistic healing traditions.

In contemporary contexts, jasper continues to find application in lapidary work and industrial uses due to its hardness and attractive color variations. Its presence in geological formations provides insights into ancient environments and processes of mineral formation, contributing to broader scientific understanding and exploration of Earth’s natural history.

This package has nothing to do with rocks.

This is a personal package containing some useful functions used on a daily basis in the life of a unlikely human who happens to be a statistician working with environmental data.

Installation

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

# install.packages("devtools")
devtools::install_github("jamespyon/jspr")

Highlighted Features!!

Here are some of the main features of the jspr R package.

calculate_epc()

Taken and reformatted from atsdrepc R package, this function calculates the exposure point concentration used in health consultations or other projects. The original uses a shiny application that requires an .xlsx template input that is complicated with R. This function helps makes the process easier for those who know what to do (i.e. Don’t use this if this is your first rodeo, cowboy).

It requires an input of observations (numeric vector) and censoring (logical vector) and is best run together with dplyr verb functions group_by() and summarise(). For output, you can call for epc.

library(jspr)

#example of individual inputs
results <- rexp(n = 16, rate = 1)
nondetects <- results<0.5

calculate_epc(obs = results, cen = nondetects)$epc

#example of dplyr verbs with dataframe
library(tidyverse, quietly = TRUE)

data.frame(results, nondetects, group = rep(c("A", "B"), 8)) %>%
  group_by(group) %>%
  summarise(epc = calculate_epc(obs = results, cen = nondetects)$epc)

atsdr_footnote_symbol()

This function produces the required footnote symbol depending on the index you want. The input is a single or multiple numbers. These aren’t great to type out in R so this is useful to just have around.

library(jspr)

atsdr_footnote_symbol(1)
atsdr_footnote_symbol(1:10)

flextable_atsdr_footnote()

This is a wrapper function for atsdr_footnote_symbol() that produces footnotes for your flextable, rather than copy-and-pasting flextable::footnote() in an endless tidyverse piping loop.

library(jspr)
library(tidyverse, quietly = TRUE)
library(flextable)

example_dataset <- head(iris) |>
  flextable::flextable() |>
  flextable::set_caption(flextable::as_paragraph("Iris Title"))

add_footnotes <- data.frame(
  comment = c("col", "cell 1", "cell 1", "col", "title", "cell 2", "col 2", "cell 3", "cell 4"),
  i = c(NA, 2, 1, NA, NA, 3, NA, 4, 6),
  j = c(3, 3, 1, 2, NA, 3, 4, 4, 4)
)

example_dataset |> flextable_atsdr_footnote(add_footnotes)

example_boxplot()

This is a self contained function that makes a boxplot with labels that have the names of all the parts of a boxplot. There are also options to help you change some of the parts. More options to be added later.

library(jspr)

example_boxplot()

barkjohn_correction()

This function calculates the Barkjohn adjustment, based on EPA methods, for PurpleAir PM2.5.

barkjohn_correction(0.5, 30)

ess_test()

This function performs a T-test and applies the effective sample size adjustment for autocorrelated samples. Outputs both t.test() outputs and ess_test() outputs.

x <- rnorm(10, 0, 5)
ess_test(x)

add_metadata_marker()

This function adds metadata markers for readme.md for most repositories in compliance to the SHARE IT Act of 2024. Use this function as is and not with a script.

 \dontrun{add_metadata_marker("zzz0", exemption = "exemptByCIO", exemption_justification = "ei")}

Other Features

Coming soon to theaters near you~

About

A personal package containing useful functions used on a daily basis.

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published

Languages