I'm essentially needing to find the x value of the maximized psd in this plot. I know that the y value of interest is equal to 20405.33 + 0i. How do I index the x value for this?
The code I'm using for this plot is as follows:
ffx <- fft(spike1list)
conx <- Conj(ffx)
psd <- ffx * conx
freq <- (1:length(spike1list))/length(spike1list)*1000
plot(freq,psd, type = 'l', xlim = c(7, 8), ylim = c(0, 30000))
To find multiple peaks, R has many options, for example, findpeaks from the pracma package. findpeaks(y) returns a matrix, the second column of which gives the indices of the peaks.