RobinHankin / frab

1 stars 0 forks source link

disordR discipline violation #27

Closed RobinHankin closed 4 months ago

RobinHankin commented 4 months ago
suppressPackageStartupMessages(library("frab"))
x <- frab(c(a=-3,b=-1,c=-2,d=1,f=-1,h=1,i=-1))
x
#> A frab object with entries
#>  a  b  c  d  f  h  i 
#> -3 -1 -2  1 -1  1 -1
x[x>0]
#> A frab object with entries
#> d h 
#> 1 1
x[x>0] + 1:2
#> A frab object with entries
#> d h 
#> 2 3

Above we see a bug, surely x[x>0] + 1:2 should raise a disordR error?

RobinHankin commented 4 months ago

Note that the corresponding disordR operation, correctly, does not return an error:

  library("disordR")
#> Loading required package: Matrix
  x <- disord(c(1,1),drop=FALSE)
  x
#> A disord object with hash 00daf2a67ab53b51babb26fc0ce997076fe54351 and elements
#> [1] 1 1
#> (in some order)
  x + 1:2
#> A disord object with hash 00daf2a67ab53b51babb26fc0ce997076fe54351 and elements
#> [1] 2 3
#> (in some order)

The problem arises because x[x>0] is a _named_vector.