subset.mitml.list: Subset a list of imputed data sets

Description Usage Arguments Details Value Author(s) Examples

View source: R/subset.mitml.list.R

Description

Creates data subsets for a list of multiply imputed data sets.

Usage

1
2
## S3 method for class 'mitml.list'
subset(x, subset, select, ...)

Arguments

x

A list of imputed data sets with class mitml.list as produced by mitmlComplete (or similar).

subset

An R expression by which to subset each data set.

select

An R expression by which to select columns.

...

Not used.

Details

This function can be used to create subsets and select variables for a list of multiply imputed data sets according to the R expressions given in the subset and select arguments. The function is based on the subset function for regular data sets and works in a similar manner. Note that subsetting is performed individually for each data set. For this reason, the cases included may differ across data sets if the variables used for subsetting contain different values.

Value

A list of imputed data sets with class mitml.list.

Author(s)

Simon Grund

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
data(studentratings)

fml <- ReadDis + SES ~ ReadAchiev + (1|ID)
imp <- panImpute(studentratings, formula = fml, n.burn = 1000, n.iter = 100, m = 5)

implist <- mitmlComplete(imp)

# * Example 1: subset by SES, select variables by name
subset(implist, SES < 25, select = c(ID, FedState, Sex, SES, ReadAchiev, ReadDis))

# * Example 2: subset by FedState, select variables by column number
subset(implist, FedState == "SH", select = -c(6:7, 9:10))

## Not run: 
# * Example 3: subset by ID and Sex
subset(implist, ID 

# * Example 4: select variables by name range
subset(implist, select = ID:Sex)

## End(Not run)

mitml documentation built on Oct. 5, 2021, 5:07 p.m.