Hello R users, I am trying to use R to do the low pass filter analysis for the tidal data. I am a novice in R and so far been doing only simple stuffs on R. I found a package called signal but couldn't find the proper tutorial for the low pass filter. Could anyone point me to the proper tutorial or starting point on how to do low pass filter analysis in R ? Thank you so much. Janesh [[alternative HTML version deleted]]
Hello, If you know what a lowpass filter is, you should be able to use "filter" from "stats" package. And you can have a look at: ?triang HTH, Pascal Le 07/02/2013 09:50, Janesh Devkota a ?crit :> Hello R users, > > I am trying to use R to do the low pass filter analysis for the tidal data. > I am a novice in R and so far been doing only simple stuffs on R. I found a > package called signal but couldn't find the proper tutorial for the low > pass filter. > > Could anyone point me to the proper tutorial or starting point on how to do > low pass filter analysis in R ? > > Thank you so much. > > Janesh > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Dear Janesh Devkota, Re:> > Hello R users, > > I am trying to use R to do the low pass filter analysis for the tidal data. > I am a novice in R and so far been doing only simple stuffs on R. I found a > package called signal but couldn't find the proper tutorial for the low > pass filter. > > Could anyone point me to the proper tutorial or starting point on how to do > low pass filter analysis in R ? > > Thank you so much. > > JaneshIndeed, filters are in both the "stats" and the "signal" packages. The simplest is to define a "running average" smoothing, e.g. if your data is called "y": yfiltered = stats:::filter(y, c(1,1,1,1,1,1,1)/7) So, smooth the data by the filter c(1,1,1,1,1,1,1)/7 Note that the first 3 and last 3 data points are lost. The longer the filter, the more data at the start and the end of your data will be lost. The "signal" package allows more sphisticated forms of filter. In addition, it contains functions to compute filter types well-known in signal analysis, such as butterworth and chebysheff filters. A second-order butterworth filter with a cutoff at 0.1 x the sampling frequency: myfilter = butter(2, 0.1, type = 'low', plane='z') Apply this: yfiltered = signal:::filter(y, x) # apply filter Note that loading the "signal" package may mask the filter from "stats". Hence the call with the ::: in it. Succes. Best wishes, Franklin Bretschneider -- Dept Biologie Kruytgebouw W711 Padualaan 8 3584 CH Utrecht The Netherlands
Dear Janesh Devkota, Sorry, I forgot an edit. The last command should read: yfiltered = signal:::filter(myfilter, y) # apply filter Best wishes, Franklin Bretschneider -- Dept Biologie Kruytgebouw W711 Padualaan 8 3584 CH Utrecht The Netherlands
Janesh, This might help get you started: biostatmatt.com/archives/78 (apologies for linking to my own blog) Regards, Matt ------------------------------ Message: 51 Date: Wed, 6 Feb 2013 18:50:43 -0600 From: Janesh Devkota <janesh.devkota@gmail.com> To: r-help@r-project.org Subject: [R] low pass filter analysis in R Message-ID: <CAPTbr1rrSmUgmjjKL54u2KZzzEAFLUXALCuH=WOfrBTTAkYNEA@mail.gmail.com> Content-Type: text/plain Hello R users, I am trying to use R to do the low pass filter analysis for the tidal data. I am a novice in R and so far been doing only simple stuffs on R. I found a package called signal but couldn't find the proper tutorial for the low pass filter. Could anyone point me to the proper tutorial or starting point on how to do low pass filter analysis in R ? Thank you so much. Janesh [[alternative HTML version deleted]] [[alternative HTML version deleted]]