Filtering out a specific frequency in an analog signal
A notch filter is a good approach in general for removing an unwanted frequency. But if you are certain of the exact frequency, phase and amplitude of the unwanted sine wave, then you may also consider adding the noisy signal to a sine wave of the same frequency and amplitude but 180 degrees out of phase with the unwanted sine wave.



To illustrate the notch filter example, the plot below shows an attempt to generate a sine wave with some odd impulses (black), and then filter it with a notch filter knowing the exact frequency (red).



R code for implementing it below.



# 24782
# install.packages('signal')

T &lt;- 1024
t &lt;- 0:(T-1)

fs &lt;- 1000
omega &lt;- 2*pi*30/1000
phi &lt;- 0.9279835

x &lt;- sin(omega*t + phi)

changed &lt;- sample(1:T, 10)

y &lt;- x
y[changed] &lt;- y[changed] + 3

alpha &lt;- 0.9
num &lt;- c(1, -2*cos(omega), 1)
den &lt;- c(1, -2*alpha*cos(omega), alpha*alpha)

yf &lt;- signal::filter(num, den, y)

plot(t,y, type="l", lwd=10)
lines(t,yf, col="red", lwd=4)

legend(850, 4, c("Original", "Filtered"), lwd=c(2.5,2.5),col=c("black","red"))