#' Prepare a dataframe from a PENEPMA spectrum file
#'
#' Use the spectrum file generated by PENEPMA to create an R dataframe
#' to be used for analysis aand plotting.
#'
#' @param spcPath A string containing the file path for the spectrum
#'
#' @return the dataframe
#'
#' @keywords keywords
#'
#' @examples
#'
#' # not run...
#' # library(rEDS)
#' # fiPath <- '/pat/to/pe-spect-01.dat'
#' # df <- penepmaSpcToDF(fiPath)
#' # print(head(df))
#'
#' @export
#'
penepmaSpcToDF <- function(spcPath){
df <- read.table(spcPath, header = FALSE, sep=" ", skip=12)
# print(head(df))
df <- df[, c(4,6,8)]
keV <- df[,1]/1000.
df[,1] <- keV
names(df) <- c('keV', 'pd', 'unc')
df <- df[df$pd > 1.0e-35, ]
mv <- min(df$pd)
df$pd <- df$pd/mv
df$unc <- df$unc/mv
rownames(df) <- c()
return(df)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.