#> Warning: Code evaluation in fileio.Rmd DISABLED!

Consistent naming of file import functions in version >= 0.99

From now on, all import functions have names starting with read.*(). All functions previously named scan.*(). have been renamed accordingly.

Supported File Formats

From now on, all import functions have names starting with read.*(). All functions previously named scan.*() have been renamed accordingly.

Package hyperSpec supports a number of file formats relevant for different types of spectroscopy. This is naturally only a subset of the file formats produced by different spectroscopic equipment.

If you use package hyperSpec with data formats not mentioned in this document, please open a new issue in hyperSpec’s GitHub repository so that this document can be updated. The information should include:

  • The type of spectroscopy,
  • Spectrometer model, manufacturer, and software,
  • The “native” file format (including a sample file),
  • Description of relevant procedures to convert the file,
  • R code to import the data together with an example file that can actually be read by R,
  • Documentation, particularly the description of the data format.

If you need help finding out how to import your data, please search and eventually ask on Stackexchange with tags [r] and [spectroscopy].

Reproducing the Examples in this Manual

To run the code examples, you should create a folder named “fileio” in your working directory and copy the contents of directory https://github.com/cbeleites/hyperSpec/tree/develop/Vignettes/fileio. This online directory contains the required datasets (via git-lfs).


Introduction

This document describes how spectra can be imported into hyperSpec objects. Some possibilities to export hyperSpec objects as files are mentioned, too.

The most basic funtion to create hyperSpec objects is new("hyperSpec") (section ??). It makes a hyperSpec object from data already in R’s workspace. Thus, once the spectra are imported into R, conversion to hyperSpec objects is straightforward.

In addition, package hyperSpec comes with predifined import functions for different data formats. This document divides the discussion into dealing with ASCII files (section ??) and binary file formats (section ??). If data export for the respective format is possible, it is discussed in the same sections. As sometimes the actual data written by the spectrometer software exhibits peculiarities, package hyperSpec offers several specialized import functions. These are in general named after the data format followed by the manufacturer (e.g., read.ENVI.Nicolet).

Overview lists of the directly supported file formats are in the appendix: sorted by file format (??), manufacturer (??), and by spectroscopy (??).

Creating a hyperSpec object with new()

To create a hyperSpec object from data in R’s workspace, use:

spc <- new("hyperSpec", spc, wavelength, data, labels)

With the arguments:

spc the spectra matrix (may also be given as matrix inside column $spc of data)
wavelength the wavelength axis vector
data the extra data (possibly already including the spectra matrix in column spc)
labels a list with the proper labels. Do not forget the wavelength axis label in $.wavelength and the spectral intensity axis label in $spc.

Thus, once your data is in R’s workspace, creating a hyperSpec object is easy. I suggest wrapping the code to import your data and the line joining it into a hyperSpec object by your own import function. You are more than welcome to contribute such import code to package hyperSpec. Secion ?? discusses examples of custom import functions.

Creating a hyperSpec Object from a Data Matrix (Spectra Matrix)

As spectra matices are the internal format of hyperSpec, the consructor can directly be used:

spc <- new("hyperSpec", spc, wavelength, data, labels)

Creating a hyperSpec Object from a Data Cube (Spectra Array)

Roberto Moscetti asked how to convert a hyperspectral data cube into a hyperSpec object:

The problem is that I have a hypercube with the following dimensions: 67 × 41 × 256 y = 67 x = 41 wavelengths = 256

I do not know the way to import the hypercube.

Data cubes (i.e. 3-dimensional arrays of spectral data) result from spectal imaging measurements, where spectra are supplied for each pixel of an \(px.x × px.y\) imaging area. They have 3 directions, usually \(x\), \(y\), and the spectral dimension.

The solution is to convert the array into a spectra matrix and have separate \(x\) and \(y\) coordinates.

Assume data is the data cube, and x, y and wl hold vectors with the proper \(x\) and \(y\) coordinates and the wavelengths:

data <- array(1:24, 4:2)
wl <- c(550, 630)
x <- c(1000, 1200, 1400)
y <- c(1800, 1600, 1400, 1200)
data

Such data can be converted into a hyperSpec object by:

d <- dim(data)
dim(data) <- c(d[1] * d[2], d[3])

x <- rep(x, each = d[1])
y <- rep(y, d[2])

spectra <- new("hyperSpec",
  spc = data,
  data = data.frame(x, y), wavelength = wl
)

If no proper coordinates (vectors x, y and wl) are available, they can be left out. In the case of \(x\) and \(y\), map plotting will then be impossible, missing wavelengths will be replaced by column indices counting from 1 to d[3] automatically. Of course, such sequences (the row/column/pixel numbers) can be used instead of the original x and y as well:

y <- seq_len(d[1])
x <- seq_len(d[2])

Data cubes often come from spectral imaging systems that use an “image” coordinate system counting \(y\) from top to bottom. Note that this should accounted for in the decreasing order of the original y vector.

General behaviour of file import functions: Options file.keep.name and file.remove.emptyspc

Reading Multiple files into one hyperSpec object

Many of the function described below will work on one file, even though derived functions such as read.spc.KaiserMap() (see section ??) may take care of measurements consisting of multiple files.

Usually, the most convenient way to import multiple files into one hyperSpec object is reading all files into a list of hyperSpec objects, and then collapse()ing this list into a single hyperSpec object:

files <- Sys.glob("fileio/spc.Kaisermap/*.spc")
files <- files[seq(1, length(files), by = 2)] # import low wavenumber region only
spc <- lapply(files, read.spc)
length(spc)
spc[[1]]
spc <- collapse(spc)
spc

Note that in this particular case, the spectra are more efficiently read by read.spc.KaiserMap() (see section ??).

If you regularly import huge maps or images, writing a customized import function is highly encouraged. You may gain speed and memory by using the internal workhorse functions for the file import. In that case, please contact the package maintainer (hyperSpec’s GitHub repository) for advise (contributions to package hyperSpec are welcome and all authors are listed appropriately in the function help page’s author section).

ASCII files

Currently, hyperSpec provides two functions for general ASCII data import:

  • read.txt.long() imports long format ASCII files, i.e., one intensity value per row.
  • read.txt.wide() imports wide format ASCII files, i.e., one spectrum per row.

The import functions immediately return a hyperSpec object.

Internally, they use read.table(), a very powerful ASCII import function. R supplies another ASCII import function, scan(). Function scan() imports numeric data matrices and is faster than read.table(), but cannot import column names. If your data does not contain a header or it is not important and can safely be skipped, you may want to import your data using scan().

Note that R allows to use a variety of compressed file formats directly as ASCII files (for example, see section ??). Also, both read.txt.long() and read.txt.wide() accept connections instead of file names.

ASCII files with samples in columns

Richard Pena asked about importing another ASCII file type:

File Triazine5_31.txt corresponds to X ray powder diffraction data (Bruker AXS). The native files data“ra”are read with EVA software then they are converted into .uxd file with the File Exchange software (Bruker AXS). The .uxd file are opened with Excel software and saved as .txt file, .csv file (ChemoSpec) or .xls.

The first and following columns corresponds to the angle diffraction and the intensity values of samples respectively.

This file thus differs from the ASCII formats discussed above in that the samples are actually in columns whereas hyperSpec expects them to be in rows. The header line gives the name of the sample. Import is straightforward, just the spectra matrix needs to be transposed to make a hyperSpec object:

file <- read.table("fileio/txt.t/Triazine 5_31.txt", header = TRUE, dec = ",", sep = "\t")

triazine <- new("hyperSpec",
  wavelength = file[, 1], spc = t(file[, -1]),
  data = data.frame(sample = colnames(file[, -1])),
  labels = list(
    .wavelength = expression(2 * theta / degree),
    spc = "I / a.u."
  )
)
triazine
plot(triazine[1])

Witec also saves ASCII data with spectra in columns (Export \(\rightarrow\) Table), see ??.

JCAMP-DX

Limited import of JCAMP-DX files v. 4.24 [1] is available in function read.jdx(). These files can contain multiple spectra, supported data formats are tabular XY..XY and X++(Y..Y).

read.jdx("fileio/jcamp-dx/shimadzu.jdx", encoding = "latin1", keys.hdr2data = TRUE)
read.jdx("fileio/jcamp-dx/virgilio.jdx")

The last file has a slight inconsistenty between its meta data and spectroscopic data, causing a message. However, the difference is minute compared to the intensities. If this is known in advance, an appropriate tolerance can be chosen:

read.jdx("fileio/jcamp-dx/virgilio.jdx", ytol = 1e-9)

Function read.jdx.Shimadzu() has been removed.

An R package dedicated to importing JCAMP-DX is currently under development by Bryan Hanson (https://github.com/bryanhanson/readJDX). Package hyperSpec will use that package once it is available on CRAN. Maintenance of package hyperSpec’s read.jdx() function is limited from now on in favor of Bryan’s pacakge.

Basic Atomic Spectra from NIST Tables

The NIST (National Institute of Standards and Technology) has published a data base of basic atomic emission spectra see http://physics.nist.gov/PhysRefData/Handbook/periodictable.htm with emission lines tabulated in ASCII (HTML) files.

Here’s an example how to extract the data of the Hg strong lines file:

file <- readLines("fileio/NIST/mercurytable2.htm")
# file <- readLines("http://physics.nist.gov/PhysRefData/Handbook/Tables/mercurytable2.htm")

file <- file[-(1:grep("Intensity.*Wavelength", file) - 1)]
file <- file[1:(grep("</pre>", file) [1] - 1)]
file <- gsub("<[^>]*>", "", file)
file <- file[!grepl("^[[:space:]]+$", file)]

colnames <- file[1]
colnames <- gsub("[[:space:]][[:space:]]+", "\t", file[1])
colnames <- strsplit(colnames, "\t")[[1]]
if (!all(colnames == c("Intensity", "Wavelength (&Aring;)", "Spectrum", "Ref. "))) {
  stop("file format changed!")
}

tablestart <- grep("^[[:blank:]]*[[:alpha:]]+$", file) + 1
tableend <- c(tablestart[-1] - 2, length(file))
tables <- list()
for (t in seq_along(tablestart)) {
  tmp <- file[tablestart[t]:tableend[t]]
  tables[[t]] <- read.fwf(textConnection(tmp), c(5, 8, 12, 15, 9))
  colnames(tables[[t]]) <- c("Intensity", "persistent", "Wavelength", "Spectrum", "Ref. ")
  tables[[t]]$type <- gsub("[[:space:]]", "", file[tablestart[t] - 1])
}
tables <- do.call(rbind, tables)
levels(tables$Spectrum) <- gsub(" ", "", levels(tables$Spectrum))

Hg.AES <- list()
for (s in levels(as.factor(tables$Spectrum))) {
  Hg.AES[[s]] <- new("hyperSpec",
    wavelength = tables$Wavelength[tables$Spectrum == s],
    spc = tables$Intensity[tables$Spectrum == s],
    data = data.frame(Spectrum = s),
    label = list(
      .wavelength = expression(lambda / ring(A)),
      spc = "I"
    )
  )
}
plot(collapse(Hg.AES), lines.args = list(type = "h"), col = 1:2)

Further ASCII Formats

Further import filters are provided for manufacturer/software specific ASCII formats, see table ?? and section ??.

ASCII Export

ASCII export can be done in wide and long format using write.txt.long() and write.txt.wide(). If you need a specific header or footer, use R’s functions for writing files: write.table(), write(), cat() and so on offer fine-grained control of writing ASCII files.

Binary file formats

Matlab Files

Matlab files can be read and written using the package package R.matlab, which is available at CRAN and can be installed by install.packages("R.matlab").

spc.mat <- readMat("fileio/spectra.mat")

If the .mat file was saved with compression, the additional package package Rcompression is needed. It can be installed from omegahat:

install.packages("Rcompression", repos = "http://www.omegahat.org/R")

See the documentation of package R.matlab for more details and possibly needed further packages.

Function readMat() imports the .mat file’s contents as a list. The variables in the .mat file are properly named elements of the list. The hyperSpec object can be created using new(), see section ??.

Again, you probably want to wrap the import of your matlab files into a function.

Matlab Export

package R.matlab’s function writeMat() can be used to write R objects into .mat files. To save an hyperSpec object x for use in Matlab, you most likely want to save:

  • the wavelength axis as obtained by wl(x),
  • the spectra matrix as obtained by x[[]], and
  • possibly also the extra data as obtained by x$..
  • as well as the axis labels labels(x).
  • Alternatively, x$. yields the extra data together with the spectra matrix.

However, it may be convenient to transform the saved data according to how it is needed in Matlab. The functions as.long.df() and as.wide.df() may prove useful for reshaping the data.

Import of Matlab files written by Cytospec

A custom import function for .mat files written by Cytospec is available:

Note that Cytospec files can contain multiple versions of the data, the so-called blocks. The block to be read can be specified with the block argument. With block = TRUE, the function will read all blocks into a list:

read.mat.Cytospec("fileio/mat.cytospec/cytospec.mat", blocks = TRUE)

otherwise, select a block:

read.mat.Cytospec("fileio/mat.cytospec/cytospec.mat", blocks = 1)

Function read.cytomat is now defunct.

Function read.cytomat() has been renamed to read.mat.Cytospec() to be more consistent with the general naming scheme of the file import functions.

Please use read.mat.Cytospec() instead.

ENVI Files

ENVI files are binary data accompanied by an ASCII header file. Package hyperSpec’s function read.ENVI() can be used to import them. Usually, the header file name is the same as the binary data file name with the suffix replaced by .hdr. Otherwise, the header file name can be given via parameter headerfile.

As we experienced missing header files (Bruker’s Opus software frequently produced header files without any content), the data that would usually be read from the header file can also be handed to read.ENVI() as a list in parameter **header**. Arguments given in header replace corresponding entries of the header file. The help page gives details on what elements the list should contain, see also the discussion of ENVI files written by Bruker’s OPUS software (section ??.

Here is how to use read.ENVI():

spc <- read.ENVI("fileio/ENVI/example2.img")
spc

Please see also the manufacturer specific notes in section ??.

ENVI Export

Use package package caTools or package rgdal with GDAL for writing ENVI files.

spc Files

Thermo Galactic’s .spc file format can be imported by read.spc().

Official File Format Documentation

The specification used to be available at Thermo Scientific. Anyone knowing where it moved please contact me (hyperSpec’s GitHub repository) — I’m looking for a reasonably official website (i.e. at Thermo) rather than some random site with a copy.

A variety of sub-formats exists. package hyperSpec’s import function read.spc() does not support the old file format that was used before 1996. In addition, no test data with w planes was available — thus the import of such files could not be tested. If you come across such files, please contact the package maintainer (hyperSpec’s GitHub repository).

The header and subheader blocks of spc files store additional information of pre-defined types (see the file format specification[2]). Further information can be stored in the so-called log block at the end of the file, and should be in a key-value format (although even the official example files do not always). This information is often useful (Kaiser’s Hologram software, e.g., stores the stage position in the log block).

Function read.spc() has four arguments that allow fine-grained control of storing such information in the hyperSpec object:

keys.hdr2data parameters from the spc file and subfile headers that should become extra data columns.
keys.log2data parameters from the spc file log block that should become extra data columns.
keys.*2log parameters are deprecated because the logbook itself is depecated.

The value of these arguments can either be logical (amounting to either use all or none of the information in the file) or a character vector giving the names of the parameters that should be used. Note that the header file field names are always lowercase.

Here’s how to find out what extra information could be read from the header and log:

read.spc("fileio/spc.Kaisermap/ebroAVII.spc", keys.hdr2data = TRUE)
read.spc("fileio/spc.Kaisermap/ebroAVII.spc", keys.log2data = TRUE)

.spc files may contain multiple spectra that do not share a common wavelength axis. In this case, read.spc() returns a list of hyperSpec objects with one spectrum each. Function collapse() may be used to combine this list into one hyperSpec object:

barbiturates <- read.spc("fileio/spc/BARBITUATES.SPC")
class(barbiturates)
length(barbiturates)
barbiturates <- collapse(barbiturates, collapse.equal = FALSE)
barbiturates
barbiturates[[, , 25 ~ 30]]

Deriving manufacturer specific import filters

Please note that future changes inside the read.spc function are likely to occur. However, if you just post-process the hyperSpec object returned by read.spc(), you should be fine.

Manufacturer-Specific Discussion of File Import

Manufacturer Specific Import Functions

Many spectrometer manufacturers provide a function to export their spectra into ASCII files. The functions discussed above are written in a very general way, and are highly customizable. I recommend wrapping these calls with the appropriate settings for your spectra format in an import function. Please consider contributing such import filters to package hyperSpec: send me the documented code (for details see the box at the beginning of this document). If you are able to import data of any format not mentioned in this document (even without the need of new converters), please let me know (details again in the box at the beginning of this document).

Bruker FT-IR Imaging

We use read.ENVI() to import IR-Images collected with a Bruker Hyperion spectrometer with OPUS software. As mentioned above, the header files are frequently empty. We found the necessary information to be:

header <- list(
  samples = 64 * no.images.in.row,
  lines = 64 * no.images.in.column,
  bands = no.data.points.per.spectrum,
  `data type` = 4,
  interleave = "bip"
)

No spatial information is given in the ENVI header (if written). The lateral coordinates can be setup by specifying origin and pixel size for \(x\) and \(y\) directions. For details please see the help page.

The proprietary file format of the Opus software is not yet supported.

Nicolet FT-IR Imaging

Also Nicolet saves imaging data in ENVI files. These files use some non-standard keywords in the header file that should allow to reconstruct the lateral coordinates as well as the wavelength axes and units for wavelength and intensity axis. Package hyperSpec has a specialized function read.ENVI.Nicolet() that uses these header entries.

It seems that the position of the first spectrum is recorded in \(mu m\){}, while the pixel size is in mm. Thus a flag nicolet.correction is provided that divides the pixel size by 1000. Alternatively, the correct offset and pixel size values may be given as function arguments.

spc <- read.ENVI.Nicolet("fileio/ENVI/example2.img", nicolet.correction = TRUE)
spc ## dummy sample with all intensities zero

Varian/Agilent FT-IR Imaging

Agilent (Varian) uses a variant of ENVI (with binary header).

Kaiser Optical Systems Raman

Spectra obtained using Kaiser’s Hologram software can be saved either in their own .hol format and imported into Matlab (from where the data may be written to a .mat file readable by package R.matlab’s readMat(). Hologram can also write ASCII files and .spc files. We found working with .spc files the best option.

The spectra are usually interpolated by Hologram to an evenly spaced wavelength (or \(\Delta\tilde\nu\)) axis unless the spectra are saved in a by-pixel manner. In this case, the full spectra consist of two files with consecutive file names: one for the low and one for the high wavenumber region. See the example for .spc import.

Kaiser Optical Systems ASCII Files

The ASCII files are long format that can be imported by read.txt.long() (see section ??).

We experienced two different problems with these files:

  • If the instrument computer’s locale is set so that also the decimal separator is a comma, commas are used both as decimal and as column separator.
  • Values with a decimal fraction of \(0\) are written with decimal separator but no further digits (e.g., 2,). This may be a problem for certain conversion functions (read.table() works fi

Thus care must be taken:

## 1. import as character
tmp <- scan("fileio/txt.Kaiser/test-lo-4.txt", what = rep("character", 4), sep = ",")
tmp <- matrix(tmp, nrow = 4)

## 2. concatenate every two columns by a dot
wl <- apply(tmp[1:2, ], 2, paste, collapse = ".")
spc <- apply(tmp[3:4, ], 2, paste, collapse = ".")

## 3. convert to numeric and create hyperSpec objectne, though).

spc <- new("hyperSpec", spc = as.numeric(spc), wavelength = as.numeric(wl))
spc

Kaiser Optical Systems Raman Maps

package hyperSpec provides the function read.spc.KaiserMap() to easily import spatial collections of .spc files written by Kaiser’s Hologram software. The filenames of all .spc files to be read into one hyperSpec object can be provided either as a character vector or as a wildcard expression (e.g., "path/to/files/*.spc").

The data for the following example was saved with wavelength axis being camera pixels rather than Raman shift. Thus two files for each spectrum were saved by Hologram. Thus, a file name pattern is difficult to give and a vector of file names is used instead:

files <- Sys.glob("fileio/spc.Kaisermap/*.spc")
spc.low <- read.spc.KaiserMap(files[seq(1, length(files), by = 2)])
spc.high <- read.spc.KaiserMap(files[seq(2, length(files), by = 2)])
wl(spc.high) <- wl(spc.high) + 1340
spc

Renishaw Raman

Renishaw’s Wire software comes with an file format converter. This program can produce a long ASCII format, .spc, or .jdx files.

We experienced that the conversion to .spc is not fully reliable: maps were saved as depth profile, loosing all spatial information. In addition, an evenly spaced wavelength axis was produced, although this was de-selected in the converter. We therefore recommend using the ASCII format. Otherwise the import using read.spc() worked.

Renishaw ASCII data

An optimized import function for the ASCII files is available: read.txt.Renishaw(). The file may be compressed via gzip, bzip2, xz or lzma. Zip compressed files are read via read.zip.Renishaw(). The ASCII files can easily become very large, particularly with linefocus or streamline imaging. Function read.txt.Renishaw() provides two mechanisms to avoid running out of memory during data import. The file may be imported in chunks of a given number of lines (see the last example). read.txt.Renishaw() can calculate the correct number of wavelengths (i.e., data points per spectrum) if the system command wc is available on your computer.

In addition, the processing of the long ASCII format into the spectra matrix is done by reshaping the vector of intensities into a matrix. This process does not allow any missing values in the data. Therefore it is not possible to import multi-spectra files with individually “zapped” spectra using read.txt.Renishaw().

The second argument to read.txt.Renishaw() decides what type of experiment is imported. Supported types are:

"xyspc" maps, images, multiple spectra with \(x\) and \(y\) coordinates (default)
"spc" single spectrum
"depth", "zspc" depth series
"ts" time series

Instead of a file name, read.txt.Renishaw() accepts also a connection.

paracetamol <- read.txt.Renishaw("fileio/txt.Renishaw/paracetamol.txt", "spc")
paracetamol
read.txt.Renishaw("fileio/txt.Renishaw/laser.txt.gz", data = "ts")

Very large files can be read in chunks to save memory:

read.txt.Renishaw("fileio/txt.Renishaw/chondro.txt", nlines = 1e5, nspc = 875)

R accepts a variety of compressed file formats for ASCII files:

read.txt.Renishaw("fileio/txt.Renishaw/chondro.gz")
read.txt.Renishaw("fileio/txt.Renishaw/chondro.xz")
read.txt.Renishaw("fileio/txt.Renishaw/chondro.lzma")
read.txt.Renishaw("fileio/txt.Renishaw/chondro.gz")
read.txt.Renishaw("fileio/txt.Renishaw/chondro.bz2")
read.zip.Renishaw("fileio/txt.Renishaw/chondro.zip")

Horiba / Jobin Yvon (e.g. LabRAM)

Horiba’s Labspec software (e. g. LabRAM spectrometers) saves spectra in a wide ASCII format which is read by read.txt.Horiba(), e. g.:

spc <- read.txt.Horiba("fileio/txt.HoribaJobinYvon/ts.txt",
  cols = list(
    t = "t / s", spc = "I / a.u.",
    .wavelength = expression(Delta * tilde(nu) / cm^-1)
  )
)
spc

Note that Labspec .txt files can contains lots of spectra with zero intensity: Labspec saves a complete rectangular grid even if only part of a map was measured. These spectra are by removed by default if option file.remove.emptyspc is TRUE (the default).

For convenience, functions to further wrappers to import maps (read.txt.Horiba.xy()) and time series (read.txt.Horiba.t()) are provided.

spc <- read.txt.Horiba.xy("fileio/txt.HoribaJobinYvon/map.txt")
if (any(dim(spc) != c(141, 4, 616)) ||
  any(abs(spc) < .Machine$double.eps^.5) ||
  is.null(spc$x) || any(is.na(spc$x)) ||
  is.null(spc$y) || any(is.na(spc$y)) ||
  length(setdiff(wl(spc), 1:616)) == 0L) {
  stop("error in testing read.txt.Horiba.xy. Please contact ", maintainer("hyperSpec"))
}
spc
spc <- read.txt.Horiba.t("fileio/txt.HoribaJobinYvon/ts.txt")
if (any(dim(spc) != c(100, 3, 1024)) ||
  is.null(spc$t) || any(is.na(spc$t)) ||
  length(setdiff(wl(spc), 1:1024)) == 0L) {
  stop("error in testing read.txt.Horiba.xy. Please contact ", maintainer("hyperSpec"))
}

spc
rm(spc)

Andor Solis

Andor Solis exports ASCII files that can be read with read.asc.Andor():

read.asc.Andor("fileio/asc.Andor/ASCII-Andor-Solis.asc")

Witec

The Witec project software supports exporting spectra as Thermo Galactic .spc files.

read.spc("fileio/spc.Witec/Witec-timeseries.spc")
read.spc("fileio/spc.Witec/Witec-Map.spc")

.spc is in general the recommended format for package hyperSpec import. For imaging data no spatial information for the set of spectra is provided (in version 2.10 this export option is not supported).

Imaging data (but also single spectra and time series) can be exported as ASCII X and Y files (Save ASCII X and Save ASCII Y, not supported in version 4). These can be read by read.dat.Witec():

read.dat.Witec("fileio/txt.Witec/Witec-timeseries-x.dat")
read.dat.Witec(
  filex = "fileio/txt.Witec/Witec-Map-x.dat",
  points.per.line = 5, lines.per.image = 5, type = "map"
)

Note that the Y data files also contain a wavelength information, but (at least Witec Project 2.10) this information is always wavelength in nm, not Raman shift in wavenumbers: this is provided by the X data file only.

Another option is Witec’s txt table ASCII export (Export \(\rightarrow\) Table), which produces ASCII files with each row corresponding to one wavelength. The first column contains the wavelength axis, all further columns contain one spectrum each column. Such files can be read with read.txt.Witec():

read.txt.Witec() determines the number of wavelengths automaticallly.

Note that there are several Export Filter Options. Here you can determine, which units should be used for the export (see XUnits tab). In addition, it is possible to export two additional header lines containing information about spectra labels and units. Therefore parameters hdr.label and hdr.units have to be set properly. Otherwise, either an error will be displayed like

or the one or two wavelengths will be skipped.

Depending on the used export options the header files should look like:

For imaging data set parameter type to “map”. If the label header is exported, the spatial information can be extracted from this line. Otherwise, at least one, points.per.line or lines.per.image, has to be given manually, if not, a warning will be shown.

For line scans and z-stacks use type = "single" because the provided information are looking the same like for timeseries, so no further information can be extracted from the header files.

Since version 4 WITec Project offers the Graph ASCII export (Export \(\rightarrow\) Graph ASCII) which produces three ASCII files, named Header containing additional information, X-Axis containing the wavelength values and Y-Axis containing the spectra one spectrum in each column. Data exported in this way can be read with read.txt.Witec.Graph():

read.txt.Witec.Graph("fileio/txt.Witec/Witec-timeseries (Header).txt")
read.txt.Witec.Graph("fileio/txt.Witec/Witec-Map (Header).txt", type = "map")
read.txt.Witec.Graph("fileio/txt.Witec/nofilename (Header).txt", encoding = "latin1")

This function reads the spectra files automatically, if they are named properly and extracts additional information of the header file. As for the other Witec functions it is possible to read image data by by selecting type = "map". Line scans and z-stacks should be read as single spectra.

Writing your own Import Function

This section gives examples how to write import functions. The first example implements an import filter for an ASCII file format basically from scratch. The second example shows how to implement more details for an already existing import filter.

A new ASCII Import Function: read.txt.PerkinElmer

The raw spectra of the flu data set (see also the respective vignette) are in PerkinElmer’s ASCII file format, one spectrum per file.

We need a function that automatically reads all files specified by a pattern, such as *.txt. In order to gain speed, the spectra matrix should be preallocated after the first file is read.

A short examination of the files (flu*.txt in directory txt.PerkinElmer) reveals that the actual spectrum starts at line 55, after a line containing \#DATA. For now, no other information of the files is to be extracted. It is thus easier to skip the first 54 lines than searching for the line after \#DATA.

A fully featured import function should support:

  • Reading multiple files by giving a pattern
  • hand further arguments to scan(). This comes handy in case the function is used later to import other data types.
  • Also skipping 54 lines would be a weird default, so we rather require it to be given explicitly.
  • The same applies for the axis labels: they should default to reasonable settings for fluorescence spectra, but it should be possible to change them if needed.
  • The usual log entry arguments should be supplied.
  • A sanity check should be implemented: stop with an error if a file does not have the same wavelength axis as the others.
  • If no file can be found, an empty hyperSpec object is a reasonable result: There is no need to stop with an error, but it is polite to issue an additional warning.
  • Finally, package hyperSpec does some optional common post-processing for all imported files such as attaching the filename (or connection description) to the hyperSpec object (column filename) and deleting empty spectra. These options can be globally switched on or off by options.
# The contents of "read.txt.PerkinElmer.R"

read.txt.PerkinElmer <- function(files = stop("filenames needed"), ..., label = list()) {
  ##  set default labels
  label <- modifyList(
    list(
      .wavelength = expression(lambda / nm),
      spc = expression(I[fl] / "a.u.")
    ),
    label
  )

  if (length(files) == 0) {
    warning("No files found.")
    return(new("hyperSpec"))
  }

  ## read the first file
  buffer <- matrix(scan(files[1], ...), ncol = 2, byrow = TRUE)

  ## first column gives the wavelength vector
  wavelength <- buffer[, 1]

  ## preallocate the spectra matrix:
  ##  one row per file x as many columns as the first file has
  spc <- matrix(ncol = nrow(buffer), nrow = length(files))

  ## the first file's data goes into the first row
  spc[1, ] <- buffer[, 2]

  ## now read the remaining files
  for (f in seq(along = files)[-1]) {
    buffer <- matrix(scan(files[f], ...), ncol = 2, byrow = TRUE)

    ## check whether they have the same wavelength axis
    if (!all.equal(buffer[, 1], wavelength)) {
      stop(paste(files[f], "has different wavelength axis."))
    }

    spc[f, ] <- buffer[, 2]
  }

  ## make the hyperSpec object
  spc <- new("hyperSpec", wavelength = wavelength, spc = spc, label = label)

  ## consistent file import behaviour across import functions
  hyperSpec:::.fileio.optional(spc, files)
}

Note how the labels are set. The label with the special name .wavelength corresponds to the wavelength axis, all data columns should have a label with the same name. The spectra are always in a data column called spc.

Thus,

source("read.txt.PerkinElmer.R")
read.txt.PerkinElmer(Sys.glob("fileio/txt.PerkinElmer/flu?.txt"), skip = 54)

imports the spectra.

This function is not exported by package hyperSpec: while it is already useful for importing files, it is not yet general enough to work immediately with new data, e.g., the the file header is completely ignored. Thus information like the excitation wavelength is lost.

Deriving a More Specific Function: read.ENVI.Nicolet()

The function read.ENVI.Nicolet() is a good example for a more specific import filter derived from a general filter for the respective file type. Nicolet FT-IR Imaging software saves some non-standard keywords in the header file of the ENVI data. These information can be used to reconstruct the \(x\) and \(y\) axes of the images. The units of the spectra are saved as well.

Function read.ENVI.Nicolet() thus first adjusts the parameters for read.ENVI(). Then read.ENVI() does the main work of importing the file. The resulting hyperSpec object is post-processed according to the special header entries.

For using the function, see section ??.

# The contents of "read.ENVI.Nicolet.R"

read.ENVI.Nicolet <- function(
  file = stop("read.ENVI: file name needed"),
  headerfile = NULL,
  header = list(),
  ..., # goes to read.ENVI
  x = NA, y = NA, # NA means: use the specifications from the header file if possible
  nicolet.correction = FALSE) {


  ## the additional keywords to interprete must be read from headerfile
  headerfile <- .find.ENVI.header(file, headerfile)
  keys <- readLines(headerfile)
  keys <- .read.ENVI.split.header(keys)
  keys <- keys[c("description", "z plot titles", "pixel size")]

  header <- modifyList(keys, header)

  ## most work is done by read.ENVI
  spc <- read.ENVI(
    file = file, headerfile = headerfile, header = header, ...,
    x = if (is.na(x)) 0:1 else x,
    y = if (is.na(y)) 0:1 else y
  )

  ### From here on processing the additional keywords in Nicolet's ENVI header ****

  ## z plot titles ----------------------------------------------------------------
  ## default labels
  label <- list(
    x = expression(`/`(x, micro * m)),
    y = expression(`/`(y, micro * m)),
    spc = "I / a.u.",
    .wavelength = expression(tilde(nu) / cm^-1)
  )

  ## get labels from header information
  if (!is.null(header$"z plot titles")) {
    pattern <- "^[[:blank:]]*([[:print:]^,]+)[[:blank:]]*,.*$"
    tmp <- sub(pattern, "\\1", header$"z plot titles")

    if (grepl("Wavenumbers (cm-1)", tmp, ignore.case = TRUE)) {
      label$.wavelength <- expression(tilde(nu) / cm^(-1))
    } else {
      label$.wavelength <- tmp
    }

    pattern <- "^[[:blank:]]*[[:print:]^,]+,[[:blank:]]*([[:print:]^,]+).*$"
    tmp <- sub(pattern, "\\1", header$"z plot titles")
    if (grepl("Unknown", tmp, ignore.case = TRUE)) {
      label$spc <- "I / a.u."
    } else {
      label$spc <- tmp
    }
  }

  ## modify the labels accordingly
  spc@label <- modifyList(label, spc@label)

  ## set up spatial coordinates --------------------------------------------------
  ## look for x and y in the header only if x and y are NULL
  ## they are in `description` and `pixel size`

  ## set up regular expressions to extract the values
  p.description <- paste(
    "^Spectrum position [[:digit:]]+ of [[:digit:]]+ positions,",
    "X = ([[:digit:].-]+), Y = ([[:digit:].-]+)$"
  )
  p.pixel.size <- "^[[:blank:]]*([[:digit:].-]+),[[:blank:]]*([[:digit:].-]+).*$"

  if (is.na(x) && is.na(y) &&
    !is.null(header$description) && grepl(p.description, header$description) &&
    !is.null(header$"pixel size") && grepl(p.pixel.size, header$"pixel size")) {
    x[1] <- as.numeric(sub(p.description, "\\1", header$description))
    y[1] <- as.numeric(sub(p.description, "\\2", header$description))

    x[2] <- as.numeric(sub(p.pixel.size, "\\1", header$"pixel size"))
    y[2] <- as.numeric(sub(p.pixel.size, "\\2", header$"pixel size"))

    ## it seems that the step size is given in mm while the offset is in micron
    if (nicolet.correction) {
      x[2] <- x[2] * 1000
      y[2] <- y[2] * 1000
    }

    ## now calculate and set the x and y coordinates
    x <- x[2] * spc$x + x[1]
    if (!any(is.na(x))) {
      spc@data$x <- x
    }

    y <- y[2] * spc$y + y[1]
    if (!any(is.na(y))) {
      spc@data$y <- y
    }
  }

  spc
}

Deriving import filters for spc files

Please note that future changes inside the read.spc() function are likely to occur. However, if you just post-process the hyperSpec object returned by read.spc(), you should be fine.

Appendix A: File Import Functions

File Import Functions by Format

Type Format Manufacturer Spectroscopy Function Link Notes
Andor Solis ASCII
ASCII Andor Solis ASCII Andor Raman read.asc.Andor() ??
array
binary array ??
ASCII long
ASCII ASCII long read.txt.long() ??
ASCII ASCII long Renishaw Raman read.txt.Renishaw() ??
ASCII ASCII long Kaiser Raman read.txt.long() ?? Not recommended, see discussion
ASCII ASCII long Perkin Elmer Fluorescence read.txt.PerkinElmer() ?? Reads multiple files, needs to be sourced.
ASCII long (zipped)
ASCII ASCII long (zipped) Renishaw Raman read.zip.Renishaw() ??
ASCII wide
ASCII ASCII wide read.txt.wide() ??
ASCII ASCII wide Horiba Jobin Yvon Raman read.txt.Horiba() ?? e.g., LabRAM spectrometers
ASCII ASCII wide Horiba Jobin Yvon Raman read.txt.Horiba.xy() ?? e.g., LabRAM spectrometer maps
ASCII ASCII wide Horiba Jobin Yvon Raman read.txt.Horiba.t() ?? e.g., LabRAM spectrometer time series
ASCII wide transposed
ASCII ASCII wide transposed Witec Raman read.txt.Witec() ?? Export Table
ENVI
binary ENVI read.ENVI() ??
binary ENVI Bruker Infrared Imaging read.ENVI() ??
binary ENVI Nicolet Infrared Imaging read.ENVI.Nicolet() ??
hol
binary hol Kaiser Raman ?? via Matlab
JCAMP-DX
ASCII JCAMP-DX read.jdx() ??
ASCII JCAMP-DX Renishaw Raman read.jdx() ??
ASCII JCAMP-DX Shimadzu GCxGC-MS read.txt.Shimadzu()
ASCII JCAMP-DX PerkinElmer Infrared read.jdx() ?? import for subset of the JCAMP-DX standard
Matlab
binary Matlab Matlab R.matlab::readMat() ??
binary Matlab Cytospec read.mat.Cytospec() ??
binary Matlab Witec Raman read.mat.Witec()
matrix
binary matrix ??
Opus
binary Opus Bruker Infrared Imaging ??
other
ASCII other Shimadzu GC,GC-MS read.jdx() ?? import for subset of the JCAMP-DX standard
spc
binary spc read.spc() ??
binary spc Kaiser Raman Map read.spc.KaiserMap() ?? Reads multiple files
binary spc Kaiser Raman read.spc.Kaiser() Efficiently reads multiple files
binary spc Kaiser Raman read.spc.KaiserLowHigh() Reads multiple pairs of low and high wavenumber region spcs
binary spc Kaiser Raman read.spc() ??
binary spc Renishaw Raman read.spc() ?? Not recommended, see discussion of ASCII files.
binary spc Witec Raman read.spc() ?? spc export not available for images
binary spc Horiba Raman read.spc() ??
spe
binary spe Princeton Instruments Raman read.spe() ?? WinSpec
Witec ASCII
ASCII Witec ASCII Witec Raman read.dat.Witec() ?? Save ASCII X, Save ASCII Y
Witec Graph ASCII
ASCII Witec Graph ASCII Witec Raman read.txt.Witec.Graph() ?? Export Table in 3 separate files (Header, X-Axis, Y-Axis)

File Import Functions by Manufacturer

Type Format Manufacturer Spectroscopy Function Link Notes
Andor
ASCII Andor Solis ASCII Andor Raman read.asc.Andor() ??
Bruker
binary ENVI Bruker Infrared Imaging read.ENVI() ??
binary Opus Bruker Infrared Imaging ??
Cytospec
binary Matlab Cytospec read.mat.Cytospec() ??
Horiba
binary spc Horiba Raman read.spc() ??
Horiba Jobin Yvon
ASCII ASCII wide Horiba Jobin Yvon Raman read.txt.Horiba() ?? e.g., LabRAM spectrometers
ASCII ASCII wide Horiba Jobin Yvon Raman read.txt.Horiba.xy() ?? e.g., LabRAM spectrometer maps
ASCII ASCII wide Horiba Jobin Yvon Raman read.txt.Horiba.t() ?? e.g., LabRAM spectrometer time series
Kaiser
ASCII ASCII long Kaiser Raman read.txt.long() ?? Not recommended, see discussion
binary hol Kaiser Raman ?? via Matlab
binary spc Kaiser Raman Map read.spc.KaiserMap() ?? Reads multiple files
binary spc Kaiser Raman read.spc.Kaiser() Efficiently reads multiple files
binary spc Kaiser Raman read.spc.KaiserLowHigh() Reads multiple pairs of low and high wavenumber region spcs
binary spc Kaiser Raman read.spc() ??
Matlab
binary Matlab Matlab R.matlab::readMat() ??
Nicolet
binary ENVI Nicolet Infrared Imaging read.ENVI.Nicolet() ??
Perkin Elmer
ASCII ASCII long Perkin Elmer Fluorescence read.txt.PerkinElmer() ?? Reads multiple files, needs to be sourced.
PerkinElmer
ASCII JCAMP-DX PerkinElmer Infrared read.jdx() ?? import for subset of the JCAMP-DX standard
Princeton Instruments
binary spe Princeton Instruments Raman read.spe() ?? WinSpec
Renishaw
ASCII ASCII long Renishaw Raman read.txt.Renishaw() ??
ASCII ASCII long (zipped) Renishaw Raman read.zip.Renishaw() ??
ASCII JCAMP-DX Renishaw Raman read.jdx() ??
binary spc Renishaw Raman read.spc() ?? Not recommended, see discussion of ASCII files.
Shimadzu
ASCII other Shimadzu GC,GC-MS read.jdx() ?? import for subset of the JCAMP-DX standard
ASCII JCAMP-DX Shimadzu GCxGC-MS read.txt.Shimadzu()
Witec
ASCII Witec ASCII Witec Raman read.dat.Witec() ?? Save ASCII X, Save ASCII Y
ASCII ASCII wide transposed Witec Raman read.txt.Witec() ?? Export Table
ASCII Witec Graph ASCII Witec Raman read.txt.Witec.Graph() ?? Export Table in 3 separate files (Header, X-Axis, Y-Axis)
binary Matlab Witec Raman read.mat.Witec()
binary spc Witec Raman read.spc() ?? spc export not available for images
ASCII ASCII long read.txt.long() ??
ASCII ASCII wide read.txt.wide() ??
ASCII JCAMP-DX read.jdx() ??
binary ENVI read.ENVI() ??
binary spc read.spc() ??
binary array ??
binary matrix ??

File Import Functions by Spectroscopy

Type Format Manufacturer Spectroscopy Function Link Notes
Fluorescence
ASCII ASCII long Perkin Elmer Fluorescence read.txt.PerkinElmer() ?? Reads multiple files, needs to be sourced.
GC,GC-MS
ASCII other Shimadzu GC,GC-MS read.jdx() ?? import for subset of the JCAMP-DX standard
GCxGC-MS
ASCII JCAMP-DX Shimadzu GCxGC-MS read.txt.Shimadzu()
Infrared
ASCII JCAMP-DX PerkinElmer Infrared read.jdx() ?? import for subset of the JCAMP-DX standard
Infrared Imaging
binary ENVI Bruker Infrared Imaging read.ENVI() ??
binary Opus Bruker Infrared Imaging ??
binary ENVI Nicolet Infrared Imaging read.ENVI.Nicolet() ??
Raman
ASCII ASCII wide Horiba Jobin Yvon Raman read.txt.Horiba() ?? e.g., LabRAM spectrometers
ASCII ASCII wide Horiba Jobin Yvon Raman read.txt.Horiba.xy() ?? e.g., LabRAM spectrometer maps
ASCII ASCII wide Horiba Jobin Yvon Raman read.txt.Horiba.t() ?? e.g., LabRAM spectrometer time series
ASCII ASCII long Renishaw Raman read.txt.Renishaw() ??
ASCII ASCII long (zipped) Renishaw Raman read.zip.Renishaw() ??
ASCII ASCII long Kaiser Raman read.txt.long() ?? Not recommended, see discussion
ASCII JCAMP-DX Renishaw Raman read.jdx() ??
ASCII Witec ASCII Witec Raman read.dat.Witec() ?? Save ASCII X, Save ASCII Y
ASCII ASCII wide transposed Witec Raman read.txt.Witec() ?? Export Table
ASCII Witec Graph ASCII Witec Raman read.txt.Witec.Graph() ?? Export Table in 3 separate files (Header, X-Axis, Y-Axis)
ASCII Andor Solis ASCII Andor Raman read.asc.Andor() ??
binary Matlab Witec Raman read.mat.Witec()
binary hol Kaiser Raman ?? via Matlab
binary spc Kaiser Raman read.spc.Kaiser() Efficiently reads multiple files
binary spc Kaiser Raman read.spc.KaiserLowHigh() Reads multiple pairs of low and high wavenumber region spcs
binary spc Kaiser Raman read.spc() ??
binary spc Renishaw Raman read.spc() ?? Not recommended, see discussion of ASCII files.
binary spc Witec Raman read.spc() ?? spc export not available for images
binary spc Horiba Raman read.spc() ??
binary spe Princeton Instruments Raman read.spe() ?? WinSpec
Raman Map
binary spc Kaiser Raman Map read.spc.KaiserMap() ?? Reads multiple files
ASCII ASCII long read.txt.long() ??
ASCII ASCII wide read.txt.wide() ??
ASCII JCAMP-DX read.jdx() ??
binary Matlab Matlab R.matlab::readMat() ??
binary Matlab Cytospec read.mat.Cytospec() ??
binary ENVI read.ENVI() ??
binary spc read.spc() ??
binary array ??
binary matrix ??

Session Info

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       macOS Catalina 10.15.6      
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       UTC                         
#>  date     2020-08-11                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────────────────────────
#>  package        * version       date       lib source                            
#>  assertthat       0.2.1         2019-03-21 [1] CRAN (R 4.0.0)                    
#>  backports        1.1.8         2020-06-17 [1] CRAN (R 4.0.0)                    
#>  bookdown         0.20          2020-06-23 [1] CRAN (R 4.0.2)                    
#>  cli              2.0.2         2020-02-28 [1] CRAN (R 4.0.0)                    
#>  colorspace       1.4-1         2019-03-18 [1] CRAN (R 4.0.0)                    
#>  crayon           1.3.4         2017-09-16 [1] CRAN (R 4.0.0)                    
#>  digest           0.6.25        2020-02-23 [1] CRAN (R 4.0.0)                    
#>  dplyr            1.0.1         2020-07-31 [1] CRAN (R 4.0.2)                    
#>  ellipsis         0.3.1         2020-05-15 [1] CRAN (R 4.0.0)                    
#>  evaluate         0.14          2019-05-28 [1] CRAN (R 4.0.0)                    
#>  fansi            0.4.1         2020-01-08 [1] CRAN (R 4.0.0)                    
#>  generics         0.0.2         2018-11-29 [1] CRAN (R 4.0.0)                    
#>  ggplot2        * 3.3.2         2020-06-19 [1] CRAN (R 4.0.0)                    
#>  glue             1.4.1         2020-05-13 [1] CRAN (R 4.0.0)                    
#>  gtable           0.3.0         2019-03-25 [1] CRAN (R 4.0.0)                    
#>  highr            0.8           2019-03-20 [1] CRAN (R 4.0.0)                    
#>  hms              0.5.3         2020-01-08 [1] CRAN (R 4.0.0)                    
#>  htmltools        0.5.0         2020-06-16 [1] CRAN (R 4.0.0)                    
#>  httr             1.4.2         2020-07-20 [1] CRAN (R 4.0.2)                    
#>  hyperSpec      * 0.99-20200728 2020-08-11 [1] local                             
#>  hySpc.testthat   0.2.1         2020-06-24 [1] CRAN (R 4.0.2)                    
#>  jpeg             0.1-8.1       2019-10-24 [1] CRAN (R 4.0.0)                    
#>  kableExtra       1.1.0         2019-03-16 [1] CRAN (R 4.0.0)                    
#>  knitr            1.29          2020-06-23 [1] CRAN (R 4.0.1)                    
#>  lattice        * 0.20-41       2020-04-02 [2] CRAN (R 4.0.2)                    
#>  latticeExtra     0.6-29        2019-12-19 [1] CRAN (R 4.0.0)                    
#>  lazyeval         0.2.2         2019-03-15 [1] CRAN (R 4.0.0)                    
#>  lifecycle        0.2.0         2020-03-06 [1] CRAN (R 4.0.0)                    
#>  magrittr         1.5           2014-11-22 [1] CRAN (R 4.0.0)                    
#>  munsell          0.5.0         2018-06-12 [1] CRAN (R 4.0.0)                    
#>  pillar           1.4.6         2020-07-10 [1] CRAN (R 4.0.2)                    
#>  pkgconfig        2.0.3         2019-09-22 [1] CRAN (R 4.0.0)                    
#>  png              0.1-7         2013-12-03 [1] CRAN (R 4.0.0)                    
#>  purrr            0.3.4         2020-04-17 [1] CRAN (R 4.0.0)                    
#>  R.cache          0.14.0        2019-12-06 [1] CRAN (R 4.0.0)                    
#>  R.matlab       * 3.6.2         2018-09-27 [1] CRAN (R 4.0.0)                    
#>  R.methodsS3      1.8.0         2020-02-14 [1] CRAN (R 4.0.0)                    
#>  R.oo             1.23.0        2019-11-03 [1] CRAN (R 4.0.0)                    
#>  R.utils          2.9.2         2019-12-08 [1] CRAN (R 4.0.0)                    
#>  R6               2.4.1         2019-11-12 [1] CRAN (R 4.0.0)                    
#>  RColorBrewer     1.1-2         2014-12-07 [1] CRAN (R 4.0.0)                    
#>  Rcpp             1.0.5         2020-07-06 [1] CRAN (R 4.0.0)                    
#>  readr            1.3.1         2018-12-21 [1] CRAN (R 4.0.0)                    
#>  rematch2         2.1.2         2020-05-01 [1] CRAN (R 4.0.0)                    
#>  rlang            0.4.7         2020-07-09 [1] CRAN (R 4.0.2)                    
#>  rmarkdown        2.3.3         2020-07-27 [1] Github (rstudio/rmarkdown@204aa41)
#>  rstudioapi       0.11          2020-02-07 [1] CRAN (R 4.0.0)                    
#>  rvest            0.3.6         2020-07-25 [1] CRAN (R 4.0.2)                    
#>  scales           1.1.1         2020-05-11 [1] CRAN (R 4.0.0)                    
#>  sessioninfo      1.1.1         2018-11-05 [1] CRAN (R 4.0.0)                    
#>  stringi          1.4.6         2020-02-17 [1] CRAN (R 4.0.0)                    
#>  stringr          1.4.0         2019-02-10 [1] CRAN (R 4.0.0)                    
#>  styler           1.3.2         2020-02-23 [1] CRAN (R 4.0.0)                    
#>  testthat         2.3.2         2020-03-02 [1] CRAN (R 4.0.0)                    
#>  tibble           3.0.3         2020-07-10 [1] CRAN (R 4.0.2)                    
#>  tidyselect       1.1.0         2020-05-11 [1] CRAN (R 4.0.0)                    
#>  vctrs            0.3.2         2020-07-15 [1] CRAN (R 4.0.2)                    
#>  viridisLite      0.3.0         2018-02-01 [1] CRAN (R 4.0.0)                    
#>  webshot          0.5.2         2019-11-22 [1] CRAN (R 4.0.0)                    
#>  withr            2.2.0         2020-04-20 [1] CRAN (R 4.0.0)                    
#>  xfun             0.16          2020-07-24 [1] CRAN (R 4.0.2)                    
#>  xml2             1.3.2         2020-04-23 [1] CRAN (R 4.0.0)                    
#>  yaml             2.2.1         2020-02-01 [1] CRAN (R 4.0.0)                    
#> 
#> [1] /Users/runner/work/_temp/Library
#> [2] /Library/Frameworks/R.framework/Versions/4.0/Resources/library

References

[1] R.S. McDonald, J. Paul A. Wilks, JCAMP-dx: A standard form for the exchange of infrared spectra in computer readable form, Applied Spectroscopy. 42 (1988) 151–162.

[2] Universal data format specification, Galactic Industries Corp., 1997. http://ftirsearch.com/features/converters/gspc_udf.zip.