lets create a funtion z.test. the first argument is the vector of data, the second is the population mean, and the third is the population variance.

z.test= function(x,mu,popvar){
  one.tail.p <- NULL
  z.score <- round((mean(x)-mu)/(popvar/sqrt(length(x))),3)
one.tail.p <- round(pnorm(abs(z.score),
                          lower.tail = FALSE),
                    3)
cat("z=",z.score,"\n",
    "one-tailed probability=",one.tail.p,"\n",
    "two-tailed probability=",2*one.tail.p)
}
IQ.data <- c(100,101,104,109,125,116,105,108,110)
z.test(IQ.data,100,15)
## z= 1.733 
##  one-tailed probability= 0.042 
##  two-tailed probability= 0.084