I am working with the nhanes data from 2017-2018. I want to determine the relative risk of being overweight (Adipös) when being "Poor". And this grouped by Gender and Ethnicity. So far I have written this:
DurchgangJ%>%
mutate( bmi = Gewicht / (Körpergröße/100)^2 ) %>%
filter( Lebensalter >= 18 )%>%
filter(!is.na(bmi))%>%
filter(!is.na(Ratio))%>%
mutate (Poor = Ratio < 1.3)%>%
mutate (nichtarme = Ratio >= 1.3)%>%
mutate (Adipös= bmi>=30)%>%
mutate (Normal= bmi<30)%>%
group_by(Geschlecht, Ethnie)%>%
summarise (Arme = sum(Poor), Nicht_Arm= sum(nichtarme), Adipöse = sum (Adipös), Normal_Gewicht= sum (Normal))
which gives me the number of poor, overweight, normal weight and not poor people per gender and ethnicity:
I want to make the following calculations =
R1 = amount of overweight (Adipöse) not poor People (Nicht_Arm) / not poor people
R2 = amount of overweight poor people / poor people (Arme)
and then R2/R1
I got all the values I need apart from the amount of overweight not poor people and the amount of overweight poor people. I was thinking to maybe use the if/else function but I did not manage to make it work.
I am relatively new to R and therefore don't know really how to summarize TRUE and FALSE values. Because all I need for the overweight non poor people is the amount of where in both columns Adipös and Nicht_Arm it says TRUE.
Thank you for your help