R

How to look up timezones for 8,000 locations in R

If you have ever worked with dates and times over a wide geographical area, you will know that timezone math is tedious but important. In the forthcoming update of the rclimateca package, the list of climate locations provided in the package will contain the UTC offsets for what Environment Canada calls “local standard time”. Because the UTC offset for local standard time at each location is not provided with the list of locations from Environment Canada, I had to use the latitude and longitude of each site to obtain this information.

Abbreviating journal titles using BibTex & R

It seems that the tools for writing papers in R/RStudio keep getting better and better, to the point where it is rare that I have something I need to do to write a paper that happens outside of RStudio. One of these things is abbreviating journal names, because for whatever reason the checkbox that does this within Zotero’s BibTex export doesn’t work particularly well. My way around this in the past was to wait until the article was about to be submited, and figure everything out in Microsoft Word at the very end.

R data structures for Chemical Modeling

In the past few months I’ve done some work on PHREEQC modeling in R, as well as a whole lot of XRF data work that required converting what seemed like an ungodly number of molecular concentrations (e.g. Al2O3) into elemental concentrations (Al). Both of these highlighted a need for chemical data structures in R such that user input to easyphreeqc can be properly validated and chemical calculations can be made reproducible easily.

Using the tidyverse to wrangle core data

The paleolimnological data I work with most days is voluminous and difficult to wrangle. There are a lot of cores, a lot of variables, and a lot of parameters thanks to the multi-element analysis of the X-Ray Fluorescence spectrometer we’ve used recently on our sediment samples. However, since the advent of the tidyverse, this job has gotten a lot easier! I’ve been preparing some material to help students at the Centre for Water Resources Studies at Dalhousie and the Paleoenvironmental Research Group at Acadia handle what are quickly becoming big data projects.

Line-by-line, row-by-row...

The NatChem database from Environment Canada contains the best long-term atmospheric monitoring data that exists for Canada, similar to the National Atmospheric Deposition Program (NADP) in the US. Unlike the NADP, the distribution format associated with NatChem data is a hideous export format that looks like it was used by SAS at one point. readLines("natchem_sample.CSV", n=6) ## [1] "*DATA EXCHANGE STANDARD VERSION,NATCHEM PRECIP 2003/01/17 (1.01),,,,,,,,," ## [2] "*COMMENT,For information on this file please see the NAtChem web site http://www.

The Mineralogical Paragram

Matt Hall from Agile Geoscience recently wrote a post on the problem of finding the shortest possible pangram (sentence containing all letters in the alphabet) using only mineral names. The post goes into the details on the set cover problem, of which assembling a pangram from a list of minerals is one example. Matt’s best solution, “quartz kvanefjeldite abswurmbachite pyroxmangite”, contained 45 characters and four mineral names, and its timing coincided with a weekend where my other options were to proofread a 50-page report or do my taxes.