我有这个用于平滑光谱的代码!
list_tot <- list.files(path = ".", pattern="*.txt")
num <- as.integer(length(list_tot))
library(data.table)
DT_final_tot <- fread(file = list_tot[1])
setnames(DT_final_tot, c("Raman shift (cm-1)", list_tot[1]))
x <-DT_final_tot[[1]]
y <-DT_final_tot[[2]]
smooth_spectra <- smooth.spline(x,y, spar = NULL)
plot(x,y, type = "l", main="raw spectra", col="green")
lines(smooth_spectra,type = "l")
plot(smooth_spectra,type = "l", main="smooth spectra ")
我已经在文件夹的第一个文件中应用了代码!如何将其应用于所有文件以及如何将平滑光谱保存为 txt。文件?