I ran into the same problem as in R, which () returns an integer (0)
price = seq(4,7, by=0.0025)
allPrices = as.data.frame(price)
lookupPrice = 5.0600
which(allPrices$price == lookupPrice)
The operator which()displays integer(0)that indicates a lack of compliance. It should print 425, the corresponding line number in this sequence.
I understand that this is a floating point problem. The link assumes use all.equal(x,y)in some way.
How to include a function all.equal()in a statement which()to get the line number in allPriceswhich matches lookupPrice(in this case, 5.06)?
Is there any other approach? I need a row number, because the values in other columns at this price will be changed.
source
share