Probably basic problem but I have no idea what is happening... When I apply a function to the whole data frame I get a different value than when applying to a specific row...
# I apply a function to variables within dataframe 'data'
> HEX <- data$HEX.rain_pos*cos(asin(min(pmax(data$FAM.norm,0)/data$HEX.rain_pos, pi/4)))
# I check row 1499657:
> HEX[1499657]
[1] 1088.853
# I apply the same function to row 1499657 of the dataframe. Now I get what I expect...
>data$HEX.rain_pos[1499657]*cos(asin(min(pmax(data$FAM.norm[1499657],0)/data$HEX.rain_pos[1499657], pi/4)))
[1] 673.9898