### Power

library(pwr)
fun_calculation <- function(n,sig.level,power,alternative,es){
h <- cohen.ES(test = 'p',size = es)\$effect.size
result <- lapply(sig.level,function(x){pwr.p.test(h = h,n = n,sig.level = x,power = power,alternative = alternative)})
result.df <- data.frame(sig.level,ceiling(sapply(result,function(x)as.numeric(x[2]))))
colnames(result.df)[2] <- paste0('h=',h,',power=',power,'<br>alternative=',alternative,',Effects size=',es)
return(result.df)
}
sig.level <- seq(0.01,0.1,by=0.01)
n.df <- Reduce(function(x,y){merge(x, y)},lapply(c(0.7,0.8,0.9),function(x)fun_calculation(NULL,sig.level,x,'two.sided','small')))
n:『Number of observations』(Reference manual)
sig.level h=0.2,power=0.7
alternative=two.sided,Effects size=small
h=0.2,power=0.8
alternative=two.sided,Effects size=small
h=0.2,power=0.9
alternative=two.sided,Effects size=small
0.01 241 292 372
0.02 204 251 326
0.03 182 227 298
0.04 167 210 279
0.05 155 197 263
0.06 145 186 251
0.07 137 177 240
0.08 130 168 230
0.09 124 161 222
0.1 118 155 215

### Conventional effects size

n.df <- Reduce(function(x,y){merge(x, y)},lapply(c("small","medium","large"),function(x)fun_calculation(NULL,sig.level,0.9,'two.sided',x)))
n:『Number of observations』(Reference manual)
sig.level h=0.2,power=0.9
alternative=two.sided,Effects size=small
h=0.5,power=0.9
alternative=two.sided,Effects size=medium
h=0.8,power=0.9
alternative=two.sided,Effects size=large
0.01 372 60 24
0.02 326 53 21
0.03 298 48 19
0.04 279 45 18
0.05 263 43 17
0.06 251 41 16
0.07 240 39 15
0.08 230 37 15
0.09 222 36 14
0.1 215 35 14