sort.mitml.list: Sort a list of imputed data sets

Description Usage Arguments Details Value Author(s) Examples

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

Description

Sorts a list of multiply imputed data sets according to an R expression.

Usage

1
2
## S3 method for class 'mitml.list'
sort(x, decreasing = FALSE, by, ...)

Arguments

x

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

decreasing

Logical flag indicating if data sets should be sorted in decreasing (i.e., reversed) order. Default is 'FALSE'.

by

An R expression or a list of multiple expressions by which to sort the imputed data sets (see 'Examples').

...

Further arguments to 'order' (see 'Details').

Details

This function sorts a list of imputed data sets according to the R expression given in the by argument. The function is based on order and works in a similar manner. Note that sorting is performed individually for each data set. For this reason, the order of cases may differ across data sets if the variables used for sorting 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
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: sort by ID
sort(implist, by = ID)

# * Example 2: sort by combination of variables
sort(implist, by = list(FedState, ID, -SES))

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