Elements in a set not present in the other set. Equivalent to
setdiff()
.
Usage
subtract(object, set_in, not_in, ...)
# S4 method for class 'TidySet,characterORfactor,characterORfactor'
subtract(
object,
set_in,
not_in,
name = NULL,
keep = TRUE,
keep_relations = keep,
keep_elements = keep,
keep_sets = keep
)
Arguments
- object
A TidySet object.
- set_in
Name of the sets where the elements should be present.
- not_in
Name of the sets where the elements should not be present.
- ...
Placeholder for other arguments that could be passed to the method. Currently not used.
- name
Name of the new set. By default it adds a "C".
- keep
Logical value to keep all the other 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.
Methods (by class)
subtract( object = TidySet, set_in = characterORfactor, not_in = characterORfactor )
: Elements present in sets but not in other sets
See also
Other complements:
complement_element()
,
complement_set()
,
complement()
Other methods that create new sets:
complement_element()
,
complement_set()
,
intersection()
,
union()
Other methods:
TidySet-class
,
activate()
,
add_column()
,
add_relation()
,
arrange.TidySet()
,
cartesian()
,
complement_element()
,
complement_set()
,
complement()
,
element_size()
,
elements()
,
filter.TidySet()
,
group_by.TidySet()
,
group()
,
incidence()
,
intersection()
,
is.fuzzy()
,
is_nested()
,
move_to()
,
mutate.TidySet()
,
nElements()
,
nRelations()
,
nSets()
,
name_elements<-()
,
name_sets<-()
,
name_sets()
,
power_set()
,
pull.TidySet()
,
relations()
,
remove_column()
,
remove_element()
,
remove_relation()
,
remove_set()
,
rename_elements()
,
rename_set()
,
select.TidySet()
,
set_size()
,
sets()
,
union()
Examples
relations <- data.frame(
sets = c("A", "A", "B", "B", "C", "C"),
elements = letters[seq_len(6)],
fuzzy = runif(6)
)
TS <- tidySet(relations)
subtract(TS, "A", "B")
#> elements sets fuzzy
#> 1 a A 0.39640996
#> 2 b A 0.95948261
#> 3 c B 0.29865803
#> 4 d B 0.05020117
#> 5 e C 0.57618742
#> 6 f C 0.21790581
#> 7 a A∖B 0.39640996
#> 8 b A∖B 0.95948261
subtract(TS, "A", "B", keep = FALSE)
#> elements sets fuzzy
#> 1 a A∖B 0.3964100
#> 2 b A∖B 0.9594826