Skip to contents

Calculate the size of the elements or sets, using the fuzzy values as probabilities. First it must have active either sets or elements.

Usage

size(object, ...)

Arguments

object

A TidySet object.

...

Character vector with the name of elements or sets you want to calculate the size of.

Value

The size of the elements or sets. If there is no active slot or it is the relations slot returns the TidySet object with a warning.

See also

A related concept cardinality(). It is calculated using length_set().

Examples

rel <- data.frame(
    sets = c(rep("A", 5), "B", "C"),
    elements = c(letters[seq_len(6)], letters[6])
)
TS <- tidySet(rel)
TS <- activate(TS, "elements")
size(TS)
#>   elements size probability
#> 1        a    1           1
#> 2        b    1           1
#> 3        c    1           1
#> 4        d    1           1
#> 5        e    1           1
#> 6        f    2           1
TS <- activate(TS, "sets")
size(TS)
#>   sets size probability
#> 1    A    5           1
#> 2    B    1           1
#> 3    C    1           1
# With fuzzy sets
relations <- data.frame(
    sets = c(rep("A", 5), "B", "C"),
    elements = c(letters[seq_len(6)], letters[6]),
    fuzzy = runif(7)
)
TS <- tidySet(relations)
TS <- activate(TS, "elements")
size(TS)
#>    elements size probability
#> 1         a    0  0.24395891
#> 2         a    1  0.75604109
#> 3         b    0  0.45716285
#> 4         b    1  0.54283715
#> 5         c    0  0.76071190
#> 6         c    1  0.23928810
#> 7         d    0  0.49110643
#> 8         d    1  0.50889357
#> 9         e    0  0.58273563
#> 10        e    1  0.41726437
#> 11        f    0  0.09893038
#> 12        f    1  0.43750484
#> 13        f    2  0.46356478
TS <- activate(TS, "sets")
size(TS)
#>    sets size probability
#> 1     A    0  0.02428035
#> 2     A    1  0.15425979
#> 3     A    2  0.33585381
#> 4     A    3  0.32492060
#> 5     A    4  0.13983218
#> 6     A    5  0.02085328
#> 7     B    0  0.27305115
#> 8     B    1  0.72694885
#> 9     C    0  0.36231445
#> 10    C    1  0.63768555