I have the following data and I would like to calculate IQR for only for those whose sex is equal to 1.
I have tried
if(Agogo$sex_2015==2) { IQR(Agogo$bmi) }
Is there any way to do this using ifelse or any other condition?
I have the following data and I would like to calculate IQR for only for those whose sex is equal to 1.
I have tried
if(Agogo$sex_2015==2) { IQR(Agogo$bmi) }
Is there any way to do this using ifelse or any other condition?

I'm assuming you want the get IQR of bmi