is_group_subset: Test whether a data.frame is a proper subset of any defined...

Description Usage Arguments Value Examples

View source: R/is_group_subset.R

Description

Test whether a data.frame is a proper subset of any defined groups within a target data.frame.

Usage

1
is_group_subset(x, target, by, group)

Arguments

x

Focal data.frame, reflecting a single 'group' of interest

target

Target data.frame, containing one or more defined groups

by

Character vector giving the column(s) by which x and target should be matched and compared.

group

Name of the column within target defining groups

Value

Logical indicating whether x is a proper subset of any groups within target

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
target <- data.frame(
  g =  c("1", "1", "1",  "2", "2",  "3", "3",  "4", "4",  "5", "5"),
  x1 = c("a", "a", "a",  "b", "b",  "a", "a",  "b", "c",  "a", "b"),
  x2 = c("a", "a", "a",  "b", "b",  "a", "a",  "b", "c",  "a", "b"),
  stringsAsFactors = FALSE
)

x1 <- data.frame(
  g =  c("6", "6"),
  x1 = c("a", "a"),
  x2 = c("a", "a"),
  stringsAsFactors = FALSE
)

is_group_subset(x1, target, group = "g", by = c("x1", "x2"))

x2 <- data.frame(
  g =  c("7", "7"),
  x1 = c("a", "d"),
  x2 = c("a", "d"),
  stringsAsFactors = FALSE
)

is_group_subset(x2, target, group = "g", by = c("x1", "x2"))

epicentre-msf/llutils documentation built on Nov. 9, 2020, 8:24 p.m.