Michael Knudsen wrote:
On Fri, Jul 24, 2009 at 9:32 AM, Jan Wiener<jan.wie...@tuebingen.mpg.de> wrote:

x=sample(1:5, 115, replace=TRUE)

How do I downsample this vector to 100 entries? Are there any R
functions or packages that provide such functionality.

What exactly do you mean by downsampling?

It means that the original 115 points should be treated as a continuous function of x, or t, or whatever the horizontal axis is, with new values coming from this function at 100 evenly-spaced points along this function.

This procedure is how a sound editing program can produce a good-sounding 44.1 kHz CD quality file from material recorded at 48 kHz, for instance. Something similar happens when you ask your photo editing program to give you a smaller version of, say, a 12 Mpix picture for emailing or putting up on the web. These are all forms of interpolation.

There's a degenerate case, where the number of output samples divides evenly into the number of input samples. For instance, to downsample a 96 kHz audio file to 48 kHz, just throw away every other sample.

I, too, wish I know how to do the harder interpolation case in R. I've been in the OP's shoes, fighting with zoo and failing. The last time I had to do this, I gave up on R and did it in Mathematica. I also remember that it was easy to do this in Igor Pro when I played with its demo version.

______________________________________________
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