Assignment is: N = 500, best estimate of the effect size is correlation I calculated last week r = 0.107176 and I also want to conduct a two-tailed test with an alpha of 0.05 and I want a power of 0.80. Question is: is it worth doing the study if I can only randomly assign 500 people. (so sample size is fixed.)

The code our prof. gave us for R studio doesn't work because I am obviously missing something here.

simple.power.r<-function(n,r=NA){

#simple function to provide approximate power estimates

# (two-tailed, alpha = 0.05)

#given correlation values

#

r<-abs(r)

tvalues<-r*sqrt((n-2)/(1-(r^2)))

power <-1-pnorm(1.96(1.96-tvalue)

}

I replaced n with 500

and r with my correlation in this function before I ran it.

Any ideas what I did wrong?