downsample | R Documentation |
Interpolate a times series with a higher/lower sample rate for processes that are sensitive to low samples.
downsample(sig, dt=0.001, newdt=0.01, PLOT=FALSE )
sig |
time series vector |
dt |
sample rate s/sample |
newdt |
New, lower sample rate |
PLOT |
logical, plot both traces, default=FALSE |
Linear interpolation is performed between samples. If the newdt is an integer multiple of the old dt, The samples will not be modified.
time series vector with new sample rate.
Jonathan M. Lees<jonathan.lees@unc.edu>
data(KH)
sig = KH$JSTR[[1]]
#### reduce samples from 125 (0.008) to 25Hz (0.04)
newdt = KH$dt[1]*5
sig2 = downsample(sig, dt = KH$dt[1], newdt = newdt )
L0 = length(sig)
L1 = length(sig2)
op <- par(no.readonly = TRUE)
par(mfrow=c(2,1) )
plot.ts(ts(sig, deltat=KH$dt[1] ), xlab='s',
ylab='Amplitude', main=paste('Orignal', L0) )
grid()
plot.ts(ts(sig2, deltat=newdt ), xlab='s',
ylab='Amplitude', main=paste('Downsample', L1) )
grid()
par(op)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.