Open RobinHankin opened 1 year ago
One major problem is that the hash code of frabs with extractions defined by disords have a changed hash key:
suppressMessages(library("frab"))
set.seed(0)
options(frab_print_hash = TRUE)
x <- rfrab(10,-2:2)
x
#> A frab object with hash a6276102b30efd3240679a420b8ae6447ec0538a and entries
#> c d e g i
#> -2 -1 2 1 2
x[x<0]
#> A frab object with hash 7ce6e486250d5c2c05f3182aecefab571c377881 and entries
#> c d
#> -2 -1
Above we see that the hash key of x
and x[x<0]
are different, and arguably they should match.
It seems to be quite difficult to replace values of a frab object. Given a frab with some negative values, it is quite easy to replace the negative values with a particular scalar:
However, something like
abs(x)
seems to be much harder:Above,
x[x<0] <- -x[x<0]
would seem to have a very reasonable expectation, but it does not work, due to a lack ofsetReplaceMethod("[",signature(x="frab",i="disord",j="missing",value="frab"),...)
which would seem to be relatively straightforward to implement. Actually the best way I have found in existing package idiom to achieve
abs(x)
is this:Part of the problem is that we do not have a
values<-()
method. But I need to makevalues()
andvalues<-()
in thedisordR
package generic first.