These functions help to create a TidySet object from data.frame, list, matrix, and GO3AnnDbBimap. They can create both fuzzy and standard sets.

tidySet(relations)

# S3 method for data.frame
tidySet(relations)

# S3 method for list
tidySet(relations)

# S3 method for matrix
tidySet(relations)

# S3 method for Go3AnnDbBimap
tidySet(relations)

Arguments

relations

An object to be coerced to a TidySet.

Value

A TidySet object.

Details

Elements or sets without any relation are not shown when printed.

Methods (by class)

  • data.frame: Given the relations in a data.frame

  • list: Convert to a TidySet from a list

  • matrix: Convert an incidence matrix into a TidySet

  • Go3AnnDbBimap: Convert Go3AnnDbBimap into a TidySet object.

See also

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.6734478 #> 2 b A 0.3712699 #> 3 c A 0.9180106 #> 4 d A 0.6779781 #> 5 e A 0.6651525 #> 6 f B 0.7560411
# 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.54283715 #> 2 b Set2 0.23928810 #> 3 c Set2 0.50889357 #> 4 d Set2 0.41726437 #> 5 e Set2 0.72694885 #> 6 c <NA> 0.63768555 #> 7 d <NA> 0.39640996 #> 8 e <NA> 0.95948261 #> 9 f <NA> 0.29865803 #> 10 g <NA> 0.05020117
# 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