简体   繁体   中英

How to see the source code for bayesmeta package in R

I'm wondering how I can access the source code for function bayesmeta in the bayesmeta package. Seeing similar questions, I have tried using package:::function , using getAnywhere and methods("bayesmeta") with no success.

Is there a better way to access the source code from within R in this case?

library("bayesmeta")

bayesmeta:::bayesmeta

getAnywhere("bayesmeta")

methods("bayesmeta")

In case of doubt, I like to look at the actual source code. You can download the package source from CRAN and look directly at the source file in the R directory.

The package is available here: https://cran.r-project.org/web/packages/bayesmeta/index.html (see the "Package source" line).

Direct link to the source: https://cran.r-project.org/src/contrib/bayesmeta_2.0.tar.gz

I prefer to look at the original package source because then I see comments, functions I may not know exist, functions that are not exported, etc.

In this case, from the package source, you can see that the main function is called bayesmeta.default :

> bayesmeta:::bayesmeta.default
function (y, sigma, labels = names(y), tau.prior = "uniform", 
    mu.prior = c(mean = NA, sd = NA), mu.prior.mean = mu.prior[1], 
    mu.prior.sd = mu.prior[2], interval.type = c("shortest", 
        "central"), delta = 0.01, epsilon = 1e-04, rel.tol.integrate = 2^16 * 
        .Machine$double.eps, abs.tol.integrate = rel.tol.integrate, 
    tol.uniroot = rel.tol.integrate, ...) 
{
    ptm <- proc.time()
    y <- as.vector(y)
    sigma <- as.vector(sigma)
    labels <- as.vector(labels)
    stopifnot(is.vector(y), is.vector(sigma), all(is.finite(y)), 
        all(is.finite(sigma)), length(sigma) == length(y), all(sigma >= 
            0), sum(sigma == 0) <= 1, length(mu.prior) == 2, 
        length(mu.prior.mean) == 1, length(mu.prior.sd) == 1, 
        is.na(mu.prior.mean) || is.finite(mu.prior.mean), is.na(mu.prior.sd) || 
            (is.finite(mu.prior.mean) && (mu.prior.sd > 0)), 
        ((is.na(mu.prior.mean) & is.na(mu.prior.sd)) || (is.finite(mu.prior.mean) & 
            is.finite(mu.prior.sd))), (is.function(tau.prior) | 
            (is.character(tau.prior) && (length(tau.prior) == 
                1))))
     etc. ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM