tdaverse/ggtda

computed variable 'dim' should be made factor (not ordinal) at end of statistical transformation

Closed this issue · 0 comments

Note: This issue refers to the underway merge of the StatSimplicialComplex and main branches.

The computed variable 'dim' is assigned ordered(...) in several places, which seems to result in them occasionally being combined. This results in a warning, "Combining variables of class and was deprecated
in ggplot2 3.4.0." This suggests to me that the variable should be returned as an unordered factor (which still preserves the order of the values).

Even then, however, there is a possibility of unexpected behavior, since the smallest dimension may not always be 2—whether the combination is being done in base R or in {vctrs} (see example below).

I agree that the stat should output the variable as a factor rather than an integer, but it should be possible to store it as an integer throughout the computations and convert it to a factor just before returning.

c(factor(3:5),factor(1:3))
#> [1] 3 4 5 1 2 3
#> Levels: 3 4 5 1 2
vctrs::vec_c(factor(3:5),factor(1:3))
#> [1] 3 4 5 1 2 3
#> Levels: 3 4 5 1 2

Created on 2023-12-30 with reprex v2.0.2