RobinHankin / disordR

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

a[] <- 5 should work #4

Closed RobinHankin closed 3 years ago

RobinHankin commented 3 years ago

Look:

> a <- 1:5
> a[] <- 7
> a
[1] 7 7 7 7 7

The above idiom works fine. But:

> a <- rdisord()
> a[] <- 3
Error in a[] <- 3 : object of type 'S4' is not subsettable
> 

. . . and it really should work. See also issue #3

RobinHankin commented 3 years ago

Well it works now:

> x <- disord(runif(7))
> x[] <- 7
> x
A disord object with hash e05b0bed163e51952d2e6ae531a482e6c04881c8 and elements
[1] 7 7 7 7 7 7 7
(in some order)
> 

. . . but it works too well:

> x <- disord(runif(7))
> x[] <- 1:7
> x
A disord object with hash 6191e4163f71705d374cdbfe065561f276604e6c and elements
[1] 1 2 3 4 5 6 7
(in some order)
> 

The last line should return an error because the order is not specified.