I'm pretty new to coding, but it seems that my subset is missing values and I'm wondering what i am doing wrong. So, I have a data frame called «df_envel» with 4 colums : Elevation, distance, profil, date. I am trying to subset this dataframe to get only values that equals -0.1 m. I have tried multiple subset methods but all methods misses some -0.1 values and put some NA's instead. Here's the subset code lines I tried which all returns to the same number of values:

if should work if you would expect exact values of -0.1 to be present .
otherwise you might consider a tolerance value and looking for values +- your tolerance either side of -0.1

Alright, with the tolerance it worked! Thanks a lot. For the record, here is the line code I used :
df_envel[ which(df_envel$Elevation < -0.05 & df_envel$Elevation >-0.15),]

This is because decimals cannot always be exactly represented as floating point numbers in the computer (which uses binary storage). For example, 0.1 cannot be exactly represented.

Also, the usual way of doing it with a tolerance is this. Take the difference then use abs() to make it positive. I added a pair of brackets around (-0.1) to make it clearer for you. Also, you don't need which in your example.