Stochastic Nonsense

Put something smart here.

Unique Is Broken in R

Are you kidding me?

1
2
3
$ R
> unique(1,1,2,3,4)
[1] 1

This was the source of yesterday’s nasty to track down bug. What you really want is unique on a vector, as in:

1
2
> unique(c(1,1,2,3,4))
[1] 1 2 3 4

I can’t believe someone decided to let this silently fail in the manner most likely to screw the user. Note that other functions such as sum and max behave as expected:

1
2
3
4
> max(1,2,3,4) == max(c(1,2,3,4))
[1] TRUE
> sum(1,2,3,4) == sum(c(1,2,3,4))
[1] TRUE