`R/clean_and_downsample.R`

`downsample_time_data.Rd`

This function is useful if you were sampling at a very high frequency (eg 500Hz) causing the data size to be hard to manage, and high autocorrelation. Careful decisions should be made about the time bin size and appropriateness of this function, with respect to the data type.

`downsample_time_data(data, pupil, timebin_size, option = c("mean", "median"))`

- data
your data of class PupillometryR

- pupil
a column name denoting pupil size

- timebin_size
the size of the new timebin you wish to use

- option
what should be calculated in each timebin - mean or median. Defaults to mean.

A downsampled dataframe of class PupillometryR

```
data(pupil_data)
Sdata <- make_pupillometryr_data(data = pupil_data,
subject = ID,
trial = Trial,
time = Time,
condition = Type)
new_data <- downsample_time_data(data = Sdata,
pupil = LPupil,
timebin_size = 50,
option = 'mean')
#> Calculating mean pupil size in each timebin
```