/
relations.R
61 lines (54 loc) · 1.33 KB
/
relations.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#' @include AllClasses.R AllGenerics.R
NULL
#' @describeIn relations Retrieve the relations
#' @export
setMethod("relations",
signature = signature(object = "TidySet"),
function(object) {
slot(object, "relations")
}
)
#' @rdname relations
#' @export
replace_relations <- function(object, value) {
UseMethod("replace_relations")
}
#' @export
#' @method replace_relations TidySet
replace_relations.TidySet <- function(object, value) {
relations(object) <- value
}
#' @describeIn relations Modify the relations
#' @export
setMethod("relations<-",
signature = signature(object = "TidySet"),
function(object, value) {
slot(object, "relations") <- value
validObject(object)
object
}
)
`.relations<-` <- function(object, value) {
slot(object, "relations") <- value
}
#' @describeIn relations Return the number of unique relations
#' @export
setMethod("nRelations",
signature = signature(object = "TidySet"),
function(object) {
r <- slot(object, "relations")
nrow(unique(r[, c("sets", "elements")]))
}
)
#' @describeIn is.fuzzy Check if it is fuzzy
#' @export
setMethod("is.fuzzy",
signature = signature(object = "TidySet"),
function(object) {
if (all(relations(object)$fuzzy == 1)) {
FALSE
} else {
TRUE
}
}
)