-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresample.R
More file actions
25 lines (20 loc) · 767 Bytes
/
Copy pathresample.R
File metadata and controls
25 lines (20 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
h.format.resample <- function(timeseries = NULL, groups = NULL, old_samplerate = 1000, new_samplerate = 100) {
factor = old_samplerate/new_samplerate
new_timeseries = mean(timeseries[1:new_samplerate])
for (i in 1:floor(length(timeseries)/factor)-1) {
new_timeseries = append(new_timeseries, mean(timeseries[(new_samplerate*i)+1:(new_samplerate*i)+new_samplerate]))
}
return(new_timeseries)
}
a=(1:1000)
i=2
mean(timeseries[(new_samplerate*i)+1:(new_samplerate*i)+new_samplerate])
new_samplerate=3
mean(new_timeseries[(factor*1):(factor*1)+new_samplerate])
library(signal)
sgolayfilt(a)
new_timeseries = mean(timeseries[1:new_samplerate])
plot(new_timeseries, type='l')
plot(sgolayfilt(a), type='l')
plot(a, type='l')
plot(sgolayfilt(b), type='l')