R/clean_and_downsample.R
clean_missing_data.Rd
This function can be used to remove trials and participants who do not meet the threshold for a study. Note that there are two parameters for cleaning, one to remove trials above a threshold, the second to remove participants who drop more than a certain amount of trials.
clean_missing_data(
data,
pupil,
trial_threshold = 1,
subject_trial_threshold = 1
)
your data of class PupillometryR
a column name denoting pupil size
a proportion of missing data over which a trial can be considered lost
a proportion of missing trials over which a participant can be considered lost.
A cleaned PupillometryR dataframe
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
calculate_missing_data(data = new_data, pupil = LPupil)
#> # A tibble: 48 × 3
#> ID Trial Missing
#> <chr> <fct> <dbl>
#> 1 1 Easy1 0
#> 2 1 Hard1 0
#> 3 1 Easy2 0
#> 4 1 Hard2 0
#> 5 1 Easy3 0
#> 6 1 Hard3 0
#> 7 2 Easy1 0
#> 8 2 Hard1 0
#> 9 2 Easy2 0
#> 10 2 Hard2 0
#> # ℹ 38 more rows