using R to calculate estimates, margin of error and confidence intervals