R/pm_load_spectra.R
pm_load_spectra.Rd
pm_load_spectra
takes a column with file names for files containing
mid infrared spectra from a data frame, imports the spectra into a list
column spectra
and adds them to the data frame which then becomes an
ir::ir_new_ir[ir]
object.
pm_load_spectra( x, directory = ".", .col_files = "mirs_file", .col_sample_id = "id_sample" )
x | A data frame. |
---|---|
directory | A character value specifying the directory where the files accompanying the 'pmird' database are stored. |
.col_files | The name of the column of |
.col_sample_id | The name of the column of |
x
as an object of class ir
and with a new column
spectra
.
Currently, the following file formats are supported for files storing mid infrared spectra:
csv files
Thermo Galactic's .spc files
if (FALSE) { # connect to database con <- RMariaDB::dbConnect( # ---todo: change this drv = RMariaDB::MariaDB(), dbname = "pmird", default.file = "~/my.cnf" ) # extract data x <- pm_get_dm(con, learn_keys = TRUE) %>% dm::dm_zoom_to(data) %>% dplyr::filter(id_measurement < 1000 & ! is.na(mirs_file)) %>% dm::pull_tbl() %>% as.data.frame() # close connection RMariaDB::dbDisconnect(con) # get spectra x <- pm_load_spectra(x, directory = "..", .col_files = "mirs_file", .col_sample_id = "id_measurement") class(x) }