Learn R Programming

diyar (version 0.5.1)

merge_identifiers: Merge group identifiers

Description

Consolidate two group identifiers.

Usage

merge_ids(...)

# S3 method for default merge_ids(id1, id2, tie_sort = NULL, expand = TRUE, shrink = FALSE, ...)

# S3 method for pid merge_ids(id1, id2, tie_sort = NULL, expand = TRUE, shrink = FALSE, ...)

# S3 method for epid merge_ids(id1, id2, tie_sort = NULL, expand = TRUE, shrink = FALSE, ...)

# S3 method for pane merge_ids(id1, id2, tie_sort = NULL, expand = TRUE, shrink = FALSE, ...)

Arguments

...

Other arguments

id1

[integer|epid|pid|pane].

id2

[integer|epid|pid|pane].

tie_sort

[atomic]. Preferential order for breaking tied matches.

expand

[logical]. If TRUE, id1 gains new records if id2 indicates a match. Not interchangeable with shrink.

shrink

[logical]. If TRUE, id1 loses existing records id2 does not indicate a match. Not interchangeable with expand.

Details

Groups in id1 are expanded or shrunk by groups in id2.

A unique group with only one record is considered a non-matching record.

Note that the expand and shrink features are not interchangeable. The outcome when shrink is TRUE is not the same when expand is FALSE. See Examples.

See Also

links; links_af_probabilistic

Examples

Run this code
id1 <- rep(1, 5)
id2 <- c(2, 2, 3, 3, 3)
merge_ids(id1, id2, shrink = TRUE)

id1 <- c(rep(1, 3), 6, 7)
id2 <- c(2,2,3,3,3)
merge_ids(id1, id2, shrink = TRUE)
merge_ids(id1, id2, expand = FALSE)

id1 <- rep(1, 5)
id2 <- c(1:3, 4, 4)
merge_ids(id1, id2, shrink = TRUE)
merge_ids(id1, id2, expand= FALSE)

data(missing_staff_id)
dfr <- missing_staff_id
id1 <- links(dfr[[5]])
id2 <- links(dfr[[6]])
merge_ids(id1, id2)

Run the code above in your browser using DataLab