Functions for reading spectral data from external file types.
Currently supported reading formats are .csv and other text files, .asp,
.spa, .spc, .xyz, and .jdx.
Additionally, .0 (OPUS) and .dat (ENVI) files are supported via
read_opus()
and read_envi()
, respectively.
read_zip()
takes any of the files listed above.
Note that proprietary file formats like .0, .asp, and .spa are poorly
supported but will likely still work in most cases.
read_text(
file,
colnames = NULL,
method = "fread",
comma_decimal = TRUE,
metadata = list(file_name = basename(file), user_name = NULL, contact_info = NULL,
organization = NULL, citation = NULL, spectrum_type = NULL, spectrum_identity = NULL,
material_form = NULL, material_phase = NULL, material_producer = NULL,
material_purity = NULL, material_quality = NULL, material_color = NULL,
material_other = NULL, cas_number = NULL, instrument_used = NULL,
instrument_accessories = NULL, instrument_mode = NULL, spectral_resolution = NULL,
laser_light_used = NULL, number_of_accumulations = NULL,
total_acquisition_time_s = NULL, data_processing_procedure = NULL,
level_of_confidence_in_identification = NULL, other_info = NULL, license =
"CC BY-NC"),
...
)read_asp(
file,
metadata = list(file_name = basename(file), user_name = NULL, contact_info = NULL,
organization = NULL, citation = NULL, spectrum_type = NULL, spectrum_identity = NULL,
material_form = NULL, material_phase = NULL, material_producer = NULL,
material_purity = NULL, material_quality = NULL, material_color = NULL,
material_other = NULL, cas_number = NULL, instrument_used = NULL,
instrument_accessories = NULL, instrument_mode = NULL, spectral_resolution = NULL,
laser_light_used = NULL, number_of_accumulations = NULL,
total_acquisition_time_s = NULL, data_processing_procedure = NULL,
level_of_confidence_in_identification = NULL, other_info = NULL, license =
"CC BY-NC"),
...
)
read_spa(
file,
metadata = list(file_name = basename(file), user_name = NULL, contact_info = NULL,
organization = NULL, citation = NULL, spectrum_type = NULL, spectrum_identity = NULL,
material_form = NULL, material_phase = NULL, material_producer = NULL,
material_purity = NULL, material_quality = NULL, material_color = NULL,
material_other = NULL, cas_number = NULL, instrument_used = NULL,
instrument_accessories = NULL, instrument_mode = NULL, spectral_resolution = NULL,
laser_light_used = NULL, number_of_accumulations = NULL,
total_acquisition_time_s = NULL, data_processing_procedure = NULL,
level_of_confidence_in_identification = NULL, other_info = NULL, license =
"CC BY-NC"),
...
)
read_spc(
file,
metadata = list(file_name = basename(file), user_name = NULL, contact_info = NULL,
organization = NULL, citation = NULL, spectrum_type = NULL, spectrum_identity = NULL,
material_form = NULL, material_phase = NULL, material_producer = NULL,
material_purity = NULL, material_quality = NULL, material_color = NULL,
material_other = NULL, cas_number = NULL, instrument_used = NULL,
instrument_accessories = NULL, instrument_mode = NULL, spectral_resolution = NULL,
laser_light_used = NULL, number_of_accumulations = NULL,
total_acquisition_time_s = NULL, data_processing_procedure = NULL,
level_of_confidence_in_identification = NULL, other_info = NULL, license =
"CC BY-NC"),
...
)
read_jdx(
file,
metadata = list(file_name = basename(file), user_name = NULL, contact_info = NULL,
organization = NULL, citation = NULL, spectrum_type = NULL, spectrum_identity = NULL,
material_form = NULL, material_phase = NULL, material_producer = NULL,
material_purity = NULL, material_quality = NULL, material_color = NULL,
material_other = NULL, cas_number = NULL, instrument_used = NULL,
instrument_accessories = NULL, instrument_mode = NULL, spectral_resolution = NULL,
laser_light_used = NULL, number_of_accumulations = NULL,
total_acquisition_time_s = NULL, data_processing_procedure = NULL,
level_of_confidence_in_identification = NULL, other_info = NULL, license =
"CC BY-NC"),
...
)
read_extdata(file = NULL)
All read_*()
functions return data frames containing two columns
named "wavenumber"
and "intensity"
.
file to be read from or written to.
character vector of length = 2
indicating the column
names for the wavenumber and intensity; if NULL
columns are guessed.
submethod to be used for reading text files; defaults to
fread()
but read.csv()
works
as well.
logical(1) whether commas may represent decimals.
a named list of the metadata; see
as_OpenSpecy()
for details.
further arguments passed to the submethods.
Zacharias Steinmetz, Win Cowger
read_spc()
and read_jdx()
are wrappers around the
functions provided by the hyperSpec.
Other functions have been adapted various online sources.
Metadata is harvested if possible.
There are many unique iterations of spectral file formats so there may be
bugs in the file conversion. Please contact us if you identify any.
read_spec()
for reading .y(a)ml, .json, or .rds (OpenSpecy)
files;
read_opus()
for reading .0 (OPUS) files;
read_envi()
for reading .dat (ENVI) files;
read_zip()
and read_any()
for wrapper functions;
read.jdx()
; read.spc()
read_extdata("raman_hdpe.csv") |> read_text()
read_extdata("raman_atacamit.spc") |> read_spc()
read_extdata("ftir_ldpe_soil.asp") |> read_asp()
read_extdata("testdata_zipped.zip") |> read_zip()
Run the code above in your browser using DataLab