weathertools

Turn raw “weather-like” columns (temperature, humidity, wind, pressure, time) into clean, consistent, analysis-ready variables — without needing a meteorology background.

Heat index Dew point Wet-bulb Units + harmonization

Start here

Most users only need one of these: the PDF manual, the GitHub repo, or the install command. The PDF is the CRAN-style reference (full function documentation).

Install

Install the current version directly from GitHub:

remotes::install_github("jclark50/weathertools")

Quick examples (copy/paste)

These are the common “I have columns, I need a useful metric” cases. No special classes required — plain numeric vectors work.

Example 1 — “Feels-like hot” (Heat Index) + “mugginess” (Dew Point)

library(weathertools) ta <- c(30, 35, 40) # air temperature rh <- c(50, 60, 65) # relative humidity (%) attr(ta, "unit") <- "degC" # optional but recommended hi <- calcHI(ta, rh, outputunits = "degC") dp <- calcTD(ta, rh, outputunits = "degC") hi dp

Example 2 — Wet-bulb temperature (heat + humidity stress metric)

library(weathertools) ta <- 90; attr(ta, "unit") <- "degF" rh <- 70 wb_f <- calcWB(ta, rh) # defaults to degF output wb_c <- calcWB(ta, rh, outputunits="degC") wb_f wb_c

Example 3 — Fix unit chaos across sources (fast vector conversion)

library(weathertools) convert_units(c(300, 305), from = "K", to = "degC") # temperature convert_units(c(101325, 100800), "Pa", "hPa") # pressure convert_units(c(10, 20), "m/s", "mph") # wind speed

Example 4 — Wind direction averaging (avoids the 0/360 wraparound mistake)

library(weathertools) wd <- c(350, 10, 15, 20, 25) # degrees wsp <- c(5, 5, 5, 5, 5) # speed (same length) avgwdir(wd, wsp, movingWindow = 3)
Want the complete list of functions (with arguments)? Use the PDF manual. The manual includes the package overview and function index.

What’s inside

weathertools includes fast utilities for common weather calculations and a lightweight unit system that plays nicely with normal R workflows.

Comfort / stress metrics
Heat Index, Wet-bulb, Wind chill
Humidity helpers
Dew point, Relative Humidity
Wind tools
Direction averaging + conversions
Units + cleaning
Tag, convert, harmonize whole tables

When to use what

  • calcHI() — “feels-like hot” for warm + humid conditions
  • calcTD() — dew point (often easier to interpret than RH)
  • calcWB() — wet-bulb temperature (heat + humidity stress context)
  • avgwdir() — average wind direction correctly (handles 360/0)
  • unit() / convert_units() — lightweight unit tagging + conversion
  • wx.units() — “janitor” for renaming + unit cleanup in real-world feeds

Dataset “janitor”: wx.units()

If you ingest weather from multiple sources, you’ll run into inconsistent column names and units. wx.units() standardizes a data.table in-place: it can rename provider columns to your canonical names, convert units, tag unit attributes, and in some cases derive friendly wind fields from component columns. :contentReference[oaicite:0]{index=0}

Minimal example — rename + convert + tag units

library(data.table) library(weathertools) dt <- data.table( TMP_2m_K = c(298.15, 300.15), PRES_sfc_Pa = c(101325, 100800) ) rename_map <- c( "TMP_2m_K" = "ta", "PRES_sfc_Pa" = "pres" ) wx.units(dt, rename_map = rename_map, debug = TRUE) # dt now has: # - ta in degC # - pres in hPa # - attr(dt$ta, "unit") and attr(dt$pres, "unit") set

Direct links

Once Pages is enabled, the “clean” manual link is typically:

https://jclark50.github.io/weathertools/weathertools_1.0.0.pdf
The package manual (PDF) includes the full function index and details on unit handling, including how attr(x,"unit") is used and how strict/override modes work. :contentReference[oaicite:1]{index=1}