I want to use the baseline package in R to correct my RAMAN spectra.
My spectra data are in txt files without headers. I know the baseline package needs a matrix with all data in one row. I tried to convert my files and use the baseline package, but it didn't work. How can I use them as the input data for the package which needs a matrix and how can I get the corrected data out in a txt or csv file again? Thank you
I tried using:
library(baseline)
data <- read.delim("file.txt",sep = "\t", header=FALSE)
data.matrix <- t(data)
corrected_data <- baseline(data.matrix[1,,drop=FALSE], method='irls')`
plot(corrected_data)
Even so I don't get an error message, I see on the plots that I'm getting nonsense. The plot of the initial data is already wrong.
Your textfile needs the following structure:
Have a look at the structure of the example data provided with {baseline}:
see how the column names provide the band, starting from 4999.9... :
milk$spectraas a surrogate for our own data:column names are prefixed with 'X' now, which doesn't matter though:
request baselines for the first four spectra (rows) and store it as
bc:inspect:
retrieve the corrected spectra and store as csv: