I was working with a dataframe similar to this one, called DB_reduced:
| sex | BLT | BLN | BD | 
|---|---|---|---|
| f | NA | 45 | 2 | 
| f | 3 | 46 | NA | 
| m | 3.5 | NA | 1 | 
| f | 4 | 43 | 1 | 
| NA | 3.4 | 46 | 3 | 
| f | 3.4 | 46 | 3 | 
| NA | 3.6 | 41 | 3 | 
I was expected to get a similar result with this two codes:
DB_reduced[DB_reduced$sex == "f", 2] # first line
# or
subset(DB_reduced, DB_reduced$Sexo == "f", select = 2, drop = TRUE) # second line
but rather than just finish with the same dataframe, the first returns:
sex  BLT
f    NA
f    3
f    4
NA   3.4
f    3.4
NA   3.5
and the second:
sex  BLT
f    NA
f    3
f    4
f    3.4
Why the difference? I thought that both codes worked in tha same way. How can I modify the first line to obtain the same result as the second?
Thanks all!