R seems to degrade a list of length 1 to a scalar.
For example:
d=1:3
a=1
b=2
remains = d[c(-a, -b)]
sample(remains, 6, replace=TRUE)
This doesn't work correctly because sample() treats "remains" as a single number, and not a list of 1 element. sample returns values in the range 1:3
if I change the above code so "b=1", then sample() returns as expected.
How to fix this code without adding a special case for length(remains)==1 ?