Skip to content
Prev 85724 / 398503 Next

all.equal() and which()

On Fri, 2006-02-03 at 10:41 -0500, tom wright wrote:
There might be an easier way, but here is one approach:
[1] 24.209 24.210 24.211 24.212 24.213 24.214 24.215 24.216 24.217
[10] 24.218 24.219
[1] 3


This uses sapply() to check each element of 'mydat' against the target
value of 24.211.  The use of 'isTRUE(all.equal(...))' returns a boolean
result of either TRUE or FALSE, enabling the use of which() against the
vector returned from sapply():
[1] FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

See ?all.equal and ?isTRUE for more information.

HTH,

Marc Schwartz