use of the function if nested

Could you explain why are you saying that command doesn't work? does it produce an error message? It doesn't produce the output you are expecting? if so, what would be that output?

Also, there is no RStudio 3.6.1 version, I think you mean R 3.6.1, which is not the same, take a look to this FAQ to understand the difference.