I am trying to calculate the risk ratio for coinfection using the code:
*NET_post4['VCandShig']<-NA
NET_post4$VCandShig <- ifelse(NET_post4$VC=="Negative"& !is.na(NET_post4$VC) | NET_post4$Shigella=="Negative" & !is.na(NET_post4$Shigella), "No", "Coinf")
NET_post4$VCandShig <- ifelse(is.na(NET_post4$VC) & is.na(NET_post4$Shigella),NA,NET_post4$VCandShig)
table(NET_post4$VCandShig)
riskratio(NET_post4$VCandShig,NET_post3$SD_Cat)*
I receive the following result:
The 2x2 is correct but why is the RR estimate 1.0 with CI NA to NA? Manually I calculate based on the 2x2 that the RR is (1/9)/(74/440)=0.66
Is my code causing this problem in some way? How can I fix it?
A friend of mine pointed out that the problem can be fixed by reversing the row order of the 2x2 table with simply rev(c("rows")) so the final code is