power.r.plot {biology} | R Documentation |
~~ A concise (1-5 lines) description of what the function does. ~~
power.r.plot(r = NULL, power = NULL, n = NULL)
r |
~~Describe r here~~ |
power |
~~Describe power here~~ |
n |
~~Describe n here~~ |
~~ If necessary, more details than the description above ~~
~Describe the value returned If it is a LIST, use
comp1 |
Description of 'comp1' |
comp2 |
Description of 'comp2' |
...
....
~~further notes~~
~Make other sections like Warning with section{Warning }{....} ~
~~who you are~~
~put references to the literature/web site here ~
~~objects to See Also as help
, ~~~
##---- Should be DIRECTLY executable !! ---- ##-- ==> Define data, use random, ##-- or do help(data=index) for the standard data sets. ## The function is currently defined as function (r = NULL, power = NULL, n = NULL) { library(pwr) windows(height = 4, width = 4) old_par <- par(mar = c(4, 4, 2, 1)) if (length(n) > 0) { power_val <- numeric(length(n)) j <- 0 for (i in n) { j <- j + 1 power_val[j] <- pwr.r.test(n = i, r = r)$power } plot(n, power_val, axes = F, xlab = "", ylab = "", lwd = 2, type = "l", main = substitute(paste("r = ", r), list(r = r))) } else { n_val <- numeric(length(power)) j <- 0 for (i in power) { j <- j + 1 n_val[j] <- pwr.r.test(power = i, r = r)$n } plot(n_val, power, axes = F, xlab = "", ylab = "", lwd = 2, type = "l", main = substitute(paste("r = ", r), list(r = r))) } axis(1, tick = T, tcl = -0.2, lab = T, cex.axis = 1, lwd = 2) mtext("n", 1, font = 2, cex = 1.5, line = 3) axis(2, tick = T, tcl = -0.2, lab = T, cex.axis = 1, lwd = 2, las = 1) mtext("power", 2, font = 2, cex = 1.5, line = 3) lines(c(0, max(n)), c(0.8, 0.8), lty = 2) box(bty = "l", lwd = 2) }