The do_steps
function calculates steps for data points represented by numbers of questions from the original
experimental or survey data in x
and remaining percent of participants in y
.
Arguments
- x
Numeric vector representing the question numbers
- y
Numeric vector representing the remaining percent of participants
- return_df
Logical. If TRUE, the function returns a data frame; otherwise, it returns a list.
Details
Due to the nature of dropout/ survival data, step functions are necessary to accurately depict participants remaining. Dropout data includes the time until the event (a.k.a. dropout at a certain question or time), so that changes in remaining participants are discrete rather than continuous. This means that changes in survival probability occur at specific points and are better represented as steps than as a continuum.
Examples
x <- c(1, 2, 3, 4, 5)
y <- c(100, 100, 95, 90, 85)
do_steps(x, y)
#> x y
#> 1 1 100
#> 2 3 100
#> 3 3 95
#> 4 4 95
#> 5 4 90
#> 6 5 90
#> 7 5 85
# Using the example dataset dropRdemo
do_stats <- compute_stats(df = add_dropout_idx(dropRdemo, 3:54),
by_cond = "experimental_condition",
no_of_vars = 52)
tot_stats <- do_stats[do_stats$condition == "total", ]
do_steps(tot_stats$q_idx, tot_stats$pct_remain)
#> x y
#> 1 1 0.9552846
#> 2 2 0.9552846
#> 3 2 0.9430894
#> 4 3 0.9430894
#> 5 3 0.9065041
#> 6 4 0.9065041
#> 7 4 0.8943089
#> 8 5 0.8943089
#> 9 5 0.8902439
#> 10 6 0.8902439
#> 11 6 0.8739837
#> 12 7 0.8739837
#> 13 7 0.8577236
#> 14 8 0.8577236
#> 15 8 0.8495935
#> 16 9 0.8495935
#> 17 9 0.8455285
#> 18 10 0.8455285
#> 19 10 0.8292683
#> 20 11 0.8292683
#> 21 11 0.8252033
#> 22 12 0.8252033
#> 23 12 0.7967480
#> 24 15 0.7967480
#> 25 15 0.7886179
#> 26 16 0.7886179
#> 27 16 0.7845528
#> 28 17 0.7845528
#> 29 17 0.7804878
#> 30 18 0.7804878
#> 31 18 0.7682927
#> 32 19 0.7682927
#> 33 19 0.7601626
#> 34 20 0.7601626
#> 35 20 0.7560976
#> 36 21 0.7560976
#> 37 21 0.7479675
#> 38 22 0.7479675
#> 39 22 0.7398374
#> 40 23 0.7398374
#> 41 23 0.7317073
#> 42 25 0.7317073
#> 43 25 0.7235772
#> 44 26 0.7235772
#> 45 26 0.7195122
#> 46 27 0.7195122
#> 47 27 0.7154472
#> 48 28 0.7154472
#> 49 28 0.7113821
#> 50 29 0.7113821
#> 51 29 0.7073171
#> 52 30 0.7073171
#> 53 30 0.7032520
#> 54 31 0.7032520
#> 55 31 0.6991870
#> 56 32 0.6991870
#> 57 32 0.6951220
#> 58 33 0.6951220
#> 59 33 0.6910569
#> 60 34 0.6910569
#> 61 34 0.6869919
#> 62 35 0.6869919
#> 63 35 0.6747967
#> 64 36 0.6747967
#> 65 36 0.6666667
#> 66 37 0.6666667
#> 67 37 0.6626016
#> 68 39 0.6626016
#> 69 39 0.6585366
#> 70 40 0.6585366
#> 71 40 0.6504065
#> 72 44 0.6504065
#> 73 44 0.6463415
#> 74 45 0.6463415
#> 75 45 0.6382114
#> 76 46 0.6382114
#> 77 46 0.6300813
#> 78 47 0.6300813
#> 79 47 0.6219512
#> 80 48 0.6219512
#> 81 48 0.6178862
#> 82 52 0.6178862