user3310449
user3310449

Reputation: 33

R ChemoSpec error using files2SpectraObect: The frequency data appear to be corrupt

I trying to load NIR spectra using the ChemoSpec files2SpectraObect command. The data is coming directly from *csv files but I am getting the following error message:

files2SpectraObject(gr.crit = c("BP","TP"), + gr.cols = c("red3","dodgerblue4"), + freq.unit = "wavelength", + int.unit = "Reflectance", + descrip = "Avenue samples", + format = "csv", + out.file = "NIR.ave")

Converting integer frequency values to numeric
*** There seem to be one or more problems with these spectra!
Error in chkSpectra(spectra) : 
  Sorry, we can't continue this way: It's not me, it's you!
In addition: Warning message:
In chkSpectra(spectra) : The frequency data appear to be corrupt

setwd("W:\SciFac\OrgGeochem\Staff\Darren Beriro\PhD\R_PhD\MIR Spectral files") files2SpectraObject(gr.crit = c("bp","tp"), + gr.cols = c("red3","dodgerblue4"), + freq.unit = "Wavelenth", + int.unit = "Reflectance", + descrip = "Avenue samples", + format = "csv", + out.file = "MIR.ave")

I have check the dataframe I used to create the csv files and the wavenumber is a numeric variable. the data range is from 350 to 2500 as integers. I have loaded FTIR / MIR data in the same way - the frequency values include decimal places and these files load in fine.

Upvotes: 0

Views: 445

Answers (2)

Jeffrey Olson
Jeffrey Olson

Reputation: 11

Okay, I just went line by line through the code from files2SpectraObject and chkSpectra which is a function called inside of the first function. There are two issues that I see.

chkSpectra will throw a warning and stop the function if frequency is an integer. I don't think you can fix this in your data. It's sketchy but I recommend this fix.

fix(chkSpectra)

Remove line 81 which runs stop()

fix(files2SpectraObject)

On line 171 change saveObject() to save() with the same arguments. This appears to be a bug or a function not in a common package that I don't have.

Using fix will only temporary fix the functions so unless you save your workspace you probably need to re-run this fix every time you load csv's

Upvotes: 1

user4044189
user4044189

Reputation: 1

Check your separator and decimal symbols. Try csv2 with "," as decimal and ";" separator.

Upvotes: 0

Related Questions