I faced the problem with the library(pwr) and its function pwr.t.test.
An example from statistical textbook:
library(pwr)
pwr::pwr.t.test(-0.228, sig.level =0.05, power=0.80, type = "one.sample", alternative="less")
# Error in uniroot(function(d) eval(p.body) - power, c(-10, 5)) :
# f.lower = f(lower) is NA
#In addition: Warning messages:
#1: In qt(sig.level/tside, nu, lower = TRUE) : NaNs produced
#2: In sqrt(n/tsample) : NaNs produced
# The true answer should be be: 152.91 (153 samples)
pwr.t.test(-0.917, sig.level =0.05, power=0.80, type = "one.sample", alternative="less")
# Error in uniroot(function(d) eval(p.body) - power, c(-10, 5)) :
# f.lower = f(lower) is NA
#In addition: Warning messages:
#1: In qt(sig.level/tside, nu, lower = TRUE) : NaNs produced
#2: In sqrt(n/tsample) : NaNs produced
# True answer: 8,87 (9) samples
pwr.t.test(0.8, sig.level =0.05, power=0.80, type = "one.sample", alternative="greater")
#Error in uniroot(function(d) eval(p.body) - power, c(-5, 10)) :
# f.lower = f(lower) is NA
#In addition: Warning message:
#In qt(sig.level/tside, nu, lower = FALSE) : NaNs produced
# True answer is 11.14 (12) samples.
Do you know if R can count sample size based on t.test, or this statistical language is absent even the basic statistical functionality?
Thanks in advance for any solutions to perform this test in R :)