powerlab=function(p0,palt,new=T,color=1){
nvec=seq(10,1000,10)
power=type2=rep(NA,length(nvec))
for ( i in 1:length(nvec)){
pcrit=p0+1.645*sqrt((p0*(1-p0)/nvec[i]))
z=(pcrit-palt)/sqrt((p0*(1-p0)/nvec[i]))
power[i]=1-pnorm(z)
type2[i]=1-power[i]
if(new) plot(nvec,power,ylim=c(0,1),type="l",col=1)
else lines(nvec,power,ylim=c(0,1),type="l",col=color)
lines(nvec,type2,lty=2,col=color)
lines(nvec,type2,lty=2,col=color)
abline(h=.8,col=color)
n80=nvec[abs(power-.8)==min(abs(power-.8))]
abline(v=n80,col=color)
}
print("this function is written for a greater than test")
n80
}