如何在 R 中打开并查看包的整个脚本?

How to open and see the whole script of a package in R?

有谁知道如何在 R 中打开和查看包的整个脚本? 我们可以使用

查看包的手册pdf文件

help(package= )

但我的意思是有什么方法可以查看,例如,包中使用了哪些方程式?

我问的原因是软件包帮助(pdf 文件)不包括他们用来计算最终指数的任何方程式。所以,我不能依赖我研究领域的输出结果。

如有任何意见,我们将不胜感激。

不完全确定你在问什么,但大多数软件包都提供了一个小插图,其中包括函数原型和示例用法。

如果您的 R 环境中加载了包,您可以通过在控制台输入函数名称来查看源代码。

举个例子:

>> library(deSolve)
>> ode
function (y, times, func, parms, method = c("lsoda", "lsode", 
"lsodes", "lsodar", "vode", "daspk", "euler", "rk4", "ode23", 
"ode45", "radau", "bdf", "bdf_d", "adams", "impAdams", "impAdams_d", 
"iteration"), ...) 
{
if (is.null(method)) 
    method <- "lsoda"
if (is.list(method)) {
    if (!"rkMethod" %in% class(method)) 
        stop("'method' should be given as string or as a list of class   'rkMethod'")
    out <- rk(y, times, func, parms, method = method, ...)
}
else if (is.function(method)) 
    out <- method(y, times, func, parms, ...)
else if (is.complex(y)) 
    out <- switch(match.arg(method), vode = zvode(y, times, 
        func, parms, ...), bdf = zvode(y, times, func, parms, 
        mf = 22, ...), bdf_d = zvode(y, times, func, parms, 
        mf = 23, ...), adams = zvode(y, times, func, parms, 
        mf = 10, ...), impAdams = zvode(y, times, func, parms, 
        mf = 12, ...), impAdams_d = zvode(y, times, func, 
        parms, mf = 13, ...))
else out <- switch(match.arg(method), lsoda = lsoda(y, times, 
    func, parms, ...), vode = vode(y, times, func, parms, 
    ...), lsode = lsode(y, times, func, parms, ...), lsodes = lsodes(y, 
    times, func, parms, ...), lsodar = lsodar(y, times, func, 
    parms, ...), daspk = daspk(y, times, func, parms, ...), 
    euler = rk(y, times, func, parms, method = "euler", ...), 
    rk4 = rk(y, times, func, parms, method = "rk4", ...), 
    ode23 = rk(y, times, func, parms, method = "ode23", ...), 
    ode45 = rk(y, times, func, parms, method = "ode45", ...), 
    radau = radau(y, times, func, parms, ...), bdf = lsode(y, 
        times, func, parms, mf = 22, ...), bdf_d = lsode(y, 
        times, func, parms, mf = 23, ...), adams = lsode(y, 
        times, func, parms, mf = 10, ...), impAdams = lsode(y, 
        times, func, parms, mf = 12, ...), impAdams_d = lsode(y, 
        times, func, parms, mf = 13, ...), iteration = iteration(y, 
        times, func, parms, ...))
return(out)
}
<environment: namespace:deSolve>