Takes a movement data frame, resample numeric columns with linear interpolation and other columns with nearest label. For use with 'summarise'. For shifting the time column see correct_movement_timing

resample_movement(df, sample_rate = 10, sample_index = NULL)

Arguments

df

A movement data frame. Expected column: 'time'

sample_rate

The resampling rate in Hz. (Default 10Hz)

sample_index

time points to resample at. Overrides sample_rate if not NULL (default NULL)

Value

A resampled movement data frame

Examples

sample <- example_data$head_movement_data_0[[1]]
resample_movement(sample)
#> # A tibble: 192 × 8
#>     time   pos_x pos_y pos_z   rot_x   rot_y rot_z     n
#>    <dbl>   <dbl> <dbl> <dbl>   <dbl>   <dbl> <dbl> <dbl>
#>  1  641. 0.017    1.75 0.214  0.0389   0.107  357.     2
#>  2  641. 0.0155   1.75 0.220  0.582  360.     357.     1
#>  3  641. 0.0137   1.74 0.227  2.44   360.     357.     1
#>  4  641. 0.00878  1.73 0.241  8.09     0.469  357.     1
#>  5  642. 0.0129   1.72 0.260 12.5     10.0    358.     1
#>  6  642. 0.0219   1.72 0.276 11.5     25.2    359.     1
#>  7  642. 0.0235   1.72 0.292  8.66    37.1    359.     1
#>  8  642. 0.0162   1.72 0.312  7.61    42.6    360.     1
#>  9  642. 0.00954  1.71 0.340  8.08    43.1    360.     1
#> 10  642. 0.00787  1.71 0.384  7.93    41.2    359.     1
#> # ℹ 182 more rows