95% Confidence Interval for Proportions in R How can I calculate a 95% interval to estimate the actual proportion of SUV's in the city in R? I would like to calculate the interval on this data:
vehicleType <- c("suv", "suv", "minivan", "car", "suv", "suv", "car", "car", "car", "car", "minivan", "car", "truck", "car", "car", "car", "car", "car", "car", "car", "minivan", "car", "suv", "minivan", "car", "minivan", "suv", "suv", "suv", "car", "suv", "car", "car", "suv", "truck", "truck", "minivan", "suv", "car", "truck", "suv", "suv", "car", "car", "car", "car", "suv", "car", "car", "car", "suv", "car", "car", "car", "truck", "car", "car", "suv", "suv", "minivan", "suv", "car", "car", "car", "car", "car", "minivan", "suv", "car", "car", "suv", "minivan", "car", "car", "car", "minivan", "minivan", "minivan", "car", "truck", "car", "car", "car", "suv", "suv", "suv", "car", "suv", "suv", "car", "suv", "car", "minivan", "car", "car", "car", "car", "car", "car", "car")

Thanks in advance.
 A: First, remember that an interval for a proportion is given by:
p_hat +/- z * sqrt(p_hat * (1-p_hat)/n)

With that being said, we can use R to solve the formula like so:
# Set CI alpha level (1-alpha/2)*100%
alpha = 0.05

# Load Data
vehicleType = c("suv", "suv", "minivan", "car", "suv", "suv", "car", "car", "car", "car", "minivan", "car", "truck", "car", "car", "car", "car", "car", "car", "car", "minivan", "car", "suv", "minivan", "car", "minivan", "suv", "suv", "suv", "car", "suv", "car", "car", "suv", "truck", "truck", "minivan", "suv", "car", "truck", "suv", "suv", "car", "car", "car", "car", "suv", "car", "car", "car", "suv", "car", "car", "car", "truck", "car", "car", "suv", "suv", "minivan", "suv", "car", "car", "car", "car", "car", "minivan", "suv", "car", "car", "suv", "minivan", "car", "car", "car", "minivan", "minivan", "minivan", "car", "truck", "car", "car", "car", "suv", "suv", "suv", "car", "suv", "suv", "car", "suv", "car", "minivan", "car", "car", "car", "car", "car", "car", "car")

# Convert from string to factor
vehicleType = factor(vehicleType)

# Find the number of obs
n = length(vehicleType)

# Find number of obs per type
vtbreakdown = table(vehicleType)

# Get the proportion
p_hat = vtbreakdown['suv']/n

# Calculate the critical z-score
z = qnorm(1-alpha/2)

# Compute the CI
p_hat + c(-1,1)*z*sqrt(p_hat*(1-p_hat)/n)

So, we have:
0.1740293 0.3459707

For the p_hat of:
0.26

A: Because we are using a continuous normal distribution as an approximation of a discrete binomial distribution there should be a correction term added (0.5/N) to the above calculations:

See here for more details
