[R] looking for equivalent of matlab's medfilt1 function
Martin Maechler
maechler at stat.math.ethz.ch
Mon May 7 17:29:45 CEST 2007
>>>>> "Vladimir" == Vladimir Eremeev <wl2776 at gmail.com>
>>>>> on Mon, 7 May 2007 07:58:48 -0700 (PDT) writes:
Vladimir> Dear all,
Vladimir> I have several files with Matlab code, which I am translating to R.
Vladimir> For the zero-level approach, I took the very old
Vladimir> shell script from R-help archives, which has made
Vladimir> some obvious leg-work such as replacement of "="
Vladimir> with "<-".
Vladimir> Now I am translating indexing, matrix operations and function call using
Vladimir> this table
Vladimir> http://37mm.no/mpy/octave-r.html
You should also look at the 'matlab' package which
defines quite a few R functions such as eyes(), zeros(), repmat(),
to behave as the Matlab functions do.
Vladimir> The problem is, I cannot find the R equivalent of the matlab's function
Vladimir> medfilt1, performing 1-dimensional median filtering of a vector. Its summary
Vladimir> is here http://www-ccs.ucsd.edu/matlab/toolbox/signal/medfilt1.html
To statisticians, this has been known as "running medians",
thanks to John Tukey.
The smooth() function contains "smart" variations of
"running median of 3" which seems to be the matlab default.
For 'k > 3', I'd recommend the fast runmed(x, k)
function which also has a bit more sophisticated end-point
handling than Matlab's medfilt1() seems to provide.
Martin
More information about the R-help
mailing list