The precise interpretation of the ECG signal can reveal the condition of the heart. ECG signal analysis can assist in identifying any abnormalities or arrhythmias in the heart. Premature Ventricular Contractions (PVCs) are irregular heartbeats that may signal the presence of a heart ailment. Long-term ECGs are commonly utilized in clinical practice to diagnose PVCs. However, analyzing these long-term ECGs is time-consuming for cardiologists and requires human involvement. This research proposes a robust approach for detecting R peaks in QRS complexes using a recurrent neural network. Our proposed methodology was applied to the well-known MIT-BIH Arrhythmia Database (MIT-DB) dataset and the China Physiological Signal Challenge (2020) database, which contains over a million beats. The hybrid linearization technique uses an adaptive filter and discrete wavelet transform (DWT) to remove noise from the ECG signal. The next step is to use principle component analysis (PCA) to extract characteristics from the ECG data. Lastly, the R peak signals are classified using long short-term memory (LSTM) to improve accuracy through optimization techniques like Grey Wolf optimization (GWO). The algorithm's performance was also evaluated using the MIT-BIH Arrhythmia database and the China Physiological Signal Challenge (2020). The suggested formal technique yields the best results for R-peak detection on CPSC-DB, with F1-score of 95.3%, recall of 96.8%, accuracy of 99.5%, and precision of 95.3%. The F1-score, recall, and precision of the algorithms on MIT-DB are all equivalent to, or better than, those of the competing methods.