identical is the scalar equivalent of vectorised ==. Only returns T or F. Must use when comparing non-atomics, like lists, or envs #rstats
1
1
.@hadleywickham: counter-example: identical(1:3, seq(1,3)). There is still no scalar in R. #rstats
2
@eddelbuettel but what is that example countering?
1
.@hadleywickham Your abuse of terminology,. I'd call identical() a "bitwise object comparison". Of any R type.
1
@eddelbuettel the important thing to realise is that == is vectorised and identical is not. like pmax vs. max, sum vs colSums, etc.
1
Replying to @hadleywickham
.@hadleywickham Still don't get your point: '1:3 == rev(3:1)' works, but compares each element. So wrap all() around. Or use identical.

Jan 9, 2013 · 2:42 PM UTC

1
Replying to @eddelbuettel
@eddelbuettel if (identical(a, 1)) is more robust to unexpected input than if(a == 1). Identical is safer default when programming #rstats
1
1
1