Problem import Dataset

Dear All,

At the moment, I am trying to use an open access code "EMSC" to process spectroscopy data. The purpose of this code is to suppress the effect of fluorescence.

As input data I'm supposed to insert few Raw spectra as shown in Figure (a). The x axis is "variable" and y axis is "Relative intensity". As output parameter I'm supposed to have corrected spectra, Figure (d).

By using this little script I can run the code with their data (fishoil) and the results is shown in Figures (a-d).

Blockquote ```
library(EMSC)
data(fishoil, package = "EMSC")
Raman <- fishoil$Raman[, 850:3300]
EMSC.rep <- EMSC(Raman, degree = 6, reference = Raman[30, ],
replicates = fishoil$replicates)
plot(EMSC.rep)

Figure1

However, I didn't managed to run the code with my one Raw data. Please find it here.

I am using Rstudio for the first time. Can someone help me please.

Thank you in advance.

really does not tell us much.

Are you having a problem reading the data or in running your program? If the problem is in running the program are you getting error messages. If so, can you post them here?

For general reference you may find this usuful when asking questions here.

First of all, thank you for your reply.
Actually, the program "EMSC" contains two example of datasets. The first dataset is named "fishoil" and the other "Milk". The program works with their datasets. As I am a beginner, I don't know how to use my data instead of their data which is already contained in the program.

So I have no problem getting the program working. I don't know how to upload my data (included in my first message) and make it work with this program.

Okay, I think I see the problem, at least to some extent. I do not have EMSC so I cannot look at the example datasets but I have had a quick look at Data.txt and it is not in good shape to read into R.
It looks like the data was exported from a spreadsheet file and includes a lot of extraneous spreadsheet layout. You have two rows of text (two levels of variable names I assume) plus you have empty column separating what looks like three distinct sets of data. These things tend to confuse R.

Could you do a dput()* on one of the example data sets and post the results here to save me installing EMSC . It would help to have some idea of the expected layout.

To be honest, while R can handle these problems, it looks like a 2 minute edit in a spreadsheet might to the trick. In a spread sheet, I deleted the empty columns, deleted the first text row, renamed the variables and saved the file as a csv file.

OOPS, I forgot. The data file is using tabs as seperators. depending on the command you are using you may need to specify this. I used the R-R basic ocmmand read.csv and had to do so

dat1 <-   read.csv("datmod1.csv", sep = "\t")

where sep = "\t" tells R that we have a tab not a comma as separator.

Here is a sample of the result. Does it look like what you want?

dat1 <-   structure(list(vz1 = c(1388.560547, 1387.330078, 1386.101563, 
1384.871094, 1383.640625, 1382.410156, 1381.177734, 1379.947266, 
1378.714844, 1377.484375, 1376.251953, 1375.019531, 1373.787109, 
1372.554688, 1371.322266, 1370.089844, 1368.857422, 1367.623047, 
1366.390625, 1365.15625, 1363.921875, 1362.6875, 1361.453125, 
1360.21875, 1358.984375, 1357.75, 1356.513672, 1355.279297, 1354.042969, 
1352.806641, 1351.570313, 1350.333984, 1349.097656, 1347.861328, 
1346.625, 1345.386719, 1344.150391, 1342.912109, 1341.673828, 
1340.435547, 1339.197266, 1337.958984, 1336.720703, 1335.482422, 
1334.242188, 1333.003906, 1331.763672, 1330.523438, 1329.283203, 
1328.042969), rz1 = c(33827.945313, 34120.652344, 33531.503906, 
33722.835938, 33589.035156, 33540.589844, 33999.894531, 33569.636719, 
33468.417969, 33616.910156, 33627.335938, 33347.582031, 33698.886719, 
33494.261719, 33159.902344, 33677.320313, 33272.074219, 33256.164063, 
33428.742188, 33396.589844, 33421.175781, 33626.03125, 33397.394531, 
33025.0625, 33237.964844, 33390.058594, 33412.570313, 33259.019531, 
33222.863281, 33022.863281, 32972.597656, 33031.535156, 33074.277344, 
33145.300781, 33034.398438, 32998.292969, 33515.78125, 33146.296875, 
32954.667969, 33096.285156, 33044.03125, 33318.804688, 33113.136719, 
32923.679688, 33256.820313, 33160.1875, 32779.210938, 32942.8125, 
32789.820313, 33265.792969), vz11 = c(1388.560547, 1387.330078, 
1386.101563, 1384.871094, 1383.640625, 1382.410156, 1381.177734, 
1379.947266, 1378.714844, 1377.484375, 1376.251953, 1375.019531, 
1373.787109, 1372.554688, 1371.322266, 1370.089844, 1368.857422, 
1367.623047, 1366.390625, 1365.15625, 1363.921875, 1362.6875, 
1361.453125, 1360.21875, 1358.984375, 1357.75, 1356.513672, 1355.279297, 
1354.042969, 1352.806641, 1351.570313, 1350.333984, 1349.097656, 
1347.861328, 1346.625, 1345.386719, 1344.150391, 1342.912109, 
1341.673828, 1340.435547, 1339.197266, 1337.958984, 1336.720703, 
1335.482422, 1334.242188, 1333.003906, 1331.763672, 1330.523438, 
1329.283203, 1328.042969), rz11 = c(33268.957031, 33305.546875, 
33165.683594, 33338.789063, 33406.1875, 33311.054688, 32905.21875, 
33242.710938, 33395.332031, 33334.757813, 33132.128906, 33195.394531, 
33335.726563, 33094.648438, 33322.152344, 33253.515625, 33188.949219, 
33049.402344, 33230.125, 32973.082031, 33123.351563, 33251.285156, 
33067.269531, 32982.535156, 32776.351563, 33072.253906, 32872.1875, 
32783.484375, 33069.101563, 32990.5, 33043.382813, 32857.632813, 
33017.667969, 32791.550781, 32935.363281, 33123.578125, 33281.417969, 
32986.714844, 33243.476563, 33009.457031, 33021.824219, 33153.28125, 
32911.3125, 33393.84375, 33002.613281, 32768.855469, 33356.019531, 
33114.210938, 33344.246094, 33017.855469), vz19 = c(1388.560547, 
1387.330078, 1386.101563, 1384.871094, 1383.640625, 1382.410156, 
1381.177734, 1379.947266, 1378.714844, 1377.484375, 1376.251953, 
1375.019531, 1373.787109, 1372.554688, 1371.322266, 1370.089844, 
1368.857422, 1367.623047, 1366.390625, 1365.15625, 1363.921875, 
1362.6875, 1361.453125, 1360.21875, 1358.984375, 1357.75, 1356.513672, 
1355.279297, 1354.042969, 1352.806641, 1351.570313, 1350.333984, 
1349.097656, 1347.861328, 1346.625, 1345.386719, 1344.150391, 
1342.912109, 1341.673828, 1340.435547, 1339.197266, 1337.958984, 
1336.720703, 1335.482422, 1334.242188, 1333.003906, 1331.763672, 
1330.523438, 1329.283203, 1328.042969), rz19 = c(34163.339844, 
34382.867188, 34576.125, 34273.503906, 34168.050781, 34093.101563, 
34558.398438, 34414.359375, 34114.035156, 34169.039063, 34398.558594, 
34246.507813, 34007.269531, 34039.921875, 34175.992188, 34105.179688, 
34184.417969, 34152.132813, 34369.140625, 34600.253906, 34661.097656, 
34268.167969, 33984.734375, 34067.914063, 34242.167969, 34161.300781, 
34163.4375, 34155.449219, 34155.554688, 34250.730469, 34080.917969, 
34218.527344, 34348, 34010.46875, 34323.839844, 34180.414063, 
34190.582031, 34035.097656, 34136.164063, 34146.320313, 34229.152344, 
34118.164063, 34535.988281, 34045.617188, 34463.300781, 34104.222656, 
34180.894531, 34511.613281, 33989.398438, 34174.890625)), row.names = c(NA, 
50L), class = "data.frame")

Thank you for your answer and your time.
I will try to follow your explanation and see if it works with the ESMC package.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.