These functions help to create a TidySet
object from
data.frame
, list
, matrix
, and GO3AnnDbBimap
.
They can create both fuzzy and standard sets.
Usage
tidySet(relations)
# S3 method for class 'data.frame'
tidySet(relations)
# S3 method for class 'list'
tidySet(relations)
# S3 method for class 'matrix'
tidySet(relations)
# S3 method for class 'Go3AnnDbBimap'
tidySet(relations)
# S3 method for class 'TidySet'
tidySet(relations)
Methods (by class)
tidySet(data.frame)
: Given the relations in a data.frametidySet(list)
: Convert to a TidySet from a list.tidySet(matrix)
: Convert an incidence matrix into a TidySettidySet(Go3AnnDbBimap)
: Convert Go3AnnDbBimap into a TidySet object.tidySet(TidySet)
: Convert TidySet into a TidySet object.
Examples
relations <- data.frame(
sets = c(rep("a", 5), "b"),
elements = letters[seq_len(6)]
)
tidySet(relations)
#> elements sets fuzzy
#> 1 a a 1
#> 2 b a 1
#> 3 c a 1
#> 4 d a 1
#> 5 e a 1
#> 6 f b 1
relations2 <- data.frame(
sets = c(rep("A", 5), "B"),
elements = letters[seq_len(6)],
fuzzy = runif(6)
)
tidySet(relations2)
#> elements sets fuzzy
#> 1 a A 0.1258563
#> 2 b A 0.9381527
#> 3 c A 0.8012751
#> 4 d A 0.7580536
#> 5 e A 0.5325652
#> 6 f B 0.5468048
# A
x <- list("A" = letters[1:5], "B" = LETTERS[3:7])
tidySet(x)
#> elements sets fuzzy
#> 1 a A 1
#> 2 b A 1
#> 3 c A 1
#> 4 d A 1
#> 5 e A 1
#> 6 C B 1
#> 7 D B 1
#> 8 E B 1
#> 9 F B 1
#> 10 G B 1
# A fuzzy set taken encoded as a list
A <- runif(5)
names(A) <- letters[1:5]
B <- runif(5)
names(B) <- letters[3:7]
relations <- list(A, B)
tidySet(relations)
#> elements sets fuzzy
#> 1 a Set2 0.0959265
#> 2 b Set2 0.3883498
#> 3 c Set2 0.1723519
#> 4 d Set2 0.6907258
#> 5 e Set2 0.6752085
#> 6 c <NA> 0.9462948
#> 7 d <NA> 0.1962195
#> 8 e <NA> 0.9686375
#> 9 f <NA> 0.3870963
#> 10 g <NA> 0.6503439
# Will error
# x <- list("A" = letters[1:5], "B" = LETTERS[3:7], "c" = runif(5))
# a <- tidySet(x) # Only characters or factors are allowed as elements.
M <- matrix(c(1, 0.5, 1, 0), ncol = 2,
dimnames = list(c("A", "B"), c("a", "b")))
tidySet(M)
#> elements sets fuzzy
#> 1 A a 1.0
#> 2 B a 0.5
#> 3 A b 1.0