I am trying to find a way to calculate the FWHM of a spectra peak using R programming.
The following dataset is used to get one of the peaks:
theta <- c(32.1, 32.2, 32.3,32.4,32.5, 32.6, 32.7, 32.8, 32.9, 33.0, 33.1)
intensity <- c(0, 0, 18, 138, 405, 449, 187, 29, 2, 0, 0)
Geom_line is the way I chose to plot this. The code used:
pacman::p_load(pacman, ggplot2, dplyr, tidyverse, svglite)
DataOne <- data.frame(thetaOne, intensityOne)
view (DataOne)
PlotOne <- ggplot(data = DataOne) +
geom_line(aes(x = thetaOne, y = intensityOne))
PlotOne
My wish is after plotting the spectra I can calculate the Full Width at Half Maximum of the peaks (the width at half the height of the peak) in each spectrum. The dataset I use is much bigger than the one provided above. If possible, I would like a function that allowed me to select the region in the x axis that the peak starts and ends.
I found this: Determining FWHM from a distribution in R. However, it seems outdated, almost 5 years old. Also, I didn't understand what they proposed as a solution.