select_cases {suddengains} | R Documentation |
Select sample providing enough data to identify sudden gains
Description
Select sample for further sudden gains analyses depending on specified methods.
The following table shows the different data patterns that get selected when method = "pattern"
.
This function goes through the data and selects all cases with at least one of the following data patterns.
Pattern | x1 | x2 | x3 | x4 | x5 | x6 |
1. | x | N | x | x | . | . |
2. | x | N | x | . | x | . |
3. | x | . | N | x | x | . |
4. | x | . | N | x | . | x |
Note. x1 to x6 are consecutive data points of the primary outcome measure. 'x' = Available data; '.' = Missing data. 'N' represents available data to be examined as a possible pregain session.
Usage
select_cases(
data,
id_var_name,
sg_var_list,
method = c("pattern", "min_sess"),
min_sess_num = NULL,
return_id_lgl = FALSE
)
Arguments
data |
A dataset in wide format with an id variable and the sudden gains variables. |
id_var_name |
String, specifying the name of the ID variable. Each row should have a unique value. |
sg_var_list |
Vector, specifying the variable names of each measurement point sequentially. |
method |
String, specifying the method used to select cases: |
min_sess_num |
Numeric, minimum number of available sessions to be selected.
This argument needs to be specified if |
return_id_lgl |
Logical, if |
Value
A wide dataset indicating with all cases and a variable indicating whether each cases provides enough data to identify sudden gains.
Examples
# 1. method = "pattern"
select_cases(data = sgdata,
id_var_name = "id",
sg_var_list = c("bdi_s1", "bdi_s2", "bdi_s3", "bdi_s4",
"bdi_s5", "bdi_s6", "bdi_s7", "bdi_s8",
"bdi_s9", "bdi_s10", "bdi_s11", "bdi_s12"),
method = "pattern",
return_id_lgl = FALSE)
# 2. method = "min_sess"
select_cases(data = sgdata,
id_var_name = "id",
sg_var_list = c("bdi_s1", "bdi_s2", "bdi_s3", "bdi_s4",
"bdi_s5", "bdi_s6", "bdi_s7", "bdi_s8",
"bdi_s9", "bdi_s10", "bdi_s11", "bdi_s12"),
method = "min_sess",
min_sess_num = 9,
return_id_lgl = TRUE)