unary negation operator '-' works only with dist_normal()
venpopov opened this issue · 0 comments
venpopov commented
This works:
d1 <- -dist_normal()
These produce an error:
d2 <- -dist_gumbel()
d3 <- -dist_wrap('norm')
Error in Ops.dist_default(X[[i]], ...) :
argument "e2" is missing, with no default
Called from: inherits(e2, "dist_default")
Seems like '-' is always treated as a binary operator, expect for dist_normal()
Currently, if you want a negation, you have to do this:
d4 <- (-1) * dist_gumbel()
This is a problem for me, because I am working on a functionality for a package that plots distributions after applying link functions that could be defined by the user or come from another package. For example, this will fail with the same error:
brms::inv_logit_scaled(dist_gumbel())
although this works:
brms::inv_logit_scaled(dist_normal())
it would be great, if you can make a unary '-' operator for all distributions, including custom ones defined by dist_wrap