Skip to contents

Given a TidySet creates a new set with the elements on the both of them following the logic defined on FUN.

Usage

intersection(object, sets, ...)

# S4 method for class 'TidySet,character'
intersection(
  object,
  sets,
  name = NULL,
  FUN = "min",
  keep = FALSE,
  keep_relations = keep,
  keep_elements = keep,
  keep_sets = keep,
  ...
)

Arguments

object

A TidySet object.

sets

The character of sets to be intersect.

...

Other named arguments passed to FUN.

name

The name of the new set. By defaults joins the sets with an ∪.

FUN

A function to be applied when performing the union. The standard intersection is the "min" function, but you can provide any other function that given a numeric vector returns a single number.

keep

A logical value if you want to keep originals sets.

keep_relations

A logical value if you wan to keep old relations.

keep_elements

A logical value if you wan to keep old elements.

keep_sets

A logical value if you wan to keep old sets.

Value

A TidySet object.

Details

#' The default uses the min function following the standard fuzzy definition, but it can be changed.

Methods (by class)

  • intersection(object = TidySet, sets = character): Applies the standard intersection

Examples

rel <- data.frame(
    sets = c(rep("A", 5), "B"),
    elements = c("a", "b", "c", "d", "f", "f")
)
TS <- tidySet(rel)
intersection(TS, c("A", "B")) # Default Name
#>   elements sets fuzzy
#> 1        f  A∩B     1
intersection(TS, c("A", "B"), "C") # Set the name
#>   elements sets fuzzy
#> 1        f    C     1
# Fuzzy set
rel <- data.frame(
    sets = c(rep("A", 5), "B"),
    elements = c("a", "b", "c", "d", "f", "f"),
    fuzzy = runif(6)
)
TS2 <- tidySet(rel)
intersection(TS2, c("A", "B"), "C")
#>   elements sets     fuzzy
#> 1        f    C 0.4028812
intersection(TS2, c("A", "B"), "C", FUN = function(x){max(sqrt(x))})
#>   elements sets     fuzzy
#> 1        f    C 0.8772857