RobinHankin / disordR

https://robinhankin.github.io/disordR/
1 stars 0 forks source link

bug in replacement method #22

Closed RobinHankin closed 3 years ago

RobinHankin commented 3 years ago

Look:

> a <- disord(c(1,4,3,2))
> a[a<3]  <- c(55,56)
> a
A disord object with hash 866f83456db41e4b63abc2422390a9f0034741ff and elements
[1] 55  4  3 56
(in some order)
> 

The assignment should return an error, as it is undefined. I noticed this when playing with the mvp package:

a <- rmvp()
coeffs(a)[coeffs(a) < 4] <- c(1001,1002,1003)
RobinHankin commented 3 years ago

The problem is in consistent():

consistent <- function(x,y){allsame(x) || allsame(y) || identical(hash(x),hash(y))}`

Specifically, if x and y are regular vectors, neither of which are allsame(), then the last check, viz identical(hash(x),hash(y)) fails because neither x nor y is a disord object.