Get your own website Result Size: 625 x 565
x
 
# Specify the sample occurences (x), the sample size (n), and the null-hypothesis claim (p)
x <- 10
n <- 40
p <- 0.45
# Calculate the sample proportion
p_hat = x/n
# Calculate and print the test statistic
(p_hat-p)/(sqrt((p*(1-p))/(n)))
[1] -2.542567