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.
> 
> Janesh




Indeed, 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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to