Posts

Showing posts from April, 2026

Introducing the spectrakit R package

Image
If you regularly work with spectral data, you’ve probably run into the same set of challenges: producing clear spectral plots, combining data from multiple files, applying consistent normalization, explore patterns in the data, and assembling publication-ready figures. The spectrakit R package is designed to streamline this entire workflow. At its core, spectrakit provides a small set of focused tools for handling, analyzing and visualizing spectral data, from raw files all the way to final figures. What spectrakit does The package covers four common tasks: Visualizing spectra with flexible plotting options Combining spectra from multiple files into a single dataset Supporting exploration of spectral data using principal component analysis (PCA) Creating composite figures for publication-ready output A simple workflow A typical workflow with spectrakit might look like: ...

spectrakit Package – Part 1: Plotting Spectra in R with plotSpectra()

Image
This is part 1 of a series on the spectrakit R package. Start here for an introduction. Overview The plotSpectra() function from the spectrakit R package reads spectral data from multiple files in a folder, applies optional normalization, and produces publication-ready plots with extensive customization options. It supports multiple plotting modes, color palettes, axis formatting, annotations and automatic export of figures. This function is especially useful when working with batches of raw spectra files that require consistent and reproducible visualization. Typical use cases include exploratory comparison of spectra and generating standardized figures for reports, presentations or scientific publications. Syntax plotSpectra( folder = ".", file_type = "csv", sep = ",", header = TRUE, normalization = c("none", "simple", "min-max", "z-score", "area", "vec...

spectrakit Package – Part 2: Merging Spectra in R with combineSpectra()

This is part 2 of a series on the spectrakit R package. Start here for an introduction. Overview The combineSpectra() function from the spectrakit R package streamlines the process of merging spectral data from multiple files into a single, tidy dataset ready for analysis. It automatically reads all raw spectra files in a specified folder, aligns them by a shared variable (such as energy, wavelength or another common feature), optionally filters the data to a specific range, and applies normalization so the spectra are on comparable scales. This function shines in workflows that involve handling multiple measurement files from a specific spectrometry technique and require merging them before analysis. For example, when preparing data for multivariate analysis or machine learning, spectra must typically be aligned along a common axis and normalized to account for differences in ...

spectrakit Package – Part 3: Performing Principal Component Analysis in R with plotPCA()

Image
This is part 3 of a series on the spectrakit R package. Start here for an introduction. Overview The plotPCA() function from the spectrakit R package performs principal component analysis (PCA) on numeric variables in a dataset and generates publication-ready visualizations of scores, loadings, biplots or cumulative explained variance. It automatically handles scaling, missing values, grouping variables, confidence ellipses, customizable color palettes and figure export. This function is especially useful for exploratory multivariate analysis when patterns, clustering or dominant sources of variation are not immediately clear. Typical use cases include determining the number of relevant principal components, assessing group separation, identifying influential variables, and producing standardized PCA figures for reports, presentations or scientific publications. Syntax plotPCA( data, pcs = c(1, 2), color...

spectrakit Package – Part 4: Creating a Composite Image Grid in R with makeComposite()

Image
This is part 4 of a series on the spectrakit R package. Start here for an introduction. Overview The makeComposite() function from the spectrakit R package creates a composite image by arranging multiple sub-images into a structured grid with flexible control over layout, resizing, spacing and multi-layer labeling. This function is useful when combining figures, such as spectra, plots or image panels, into a single publication-ready output, especially when consistent sizing and precise annotation are required. It helps automate what would otherwise be a manual and error-prone process of aligning images, adjusting dimensions and adding labels for reports, presentations or scientific figures. Syntax makeComposite( folder = ".", custom_order, rows, cols, spacing = 15, resize_mode = c("none", "fit", "fill", "width", "height", "both"), labels = ...