0

Does anyone have an idea how to open and see the whole script of a package in R ? We can see the manual pdf file of the package using

help(package= )

But I mean is there any way to see, for example, what equations have been used in a package?

The reason why I am asking is the package help (pdf file), does not include any equation which they used to compute the final indices. So, I could not rely on the output results for my study area.

Any comment are appreciated.

Rebecca
  • 15
  • 4
  • Maybe this: http://stackoverflow.com/q/19226816/1412059 or this: http://stackoverflow.com/a/13181305/1412059 – Roland Oct 01 '15 at 19:20

1 Answers1

0

Not sure entirely what you are asking, but most packages provide a vignette that includes the function prototypes and example usages.

If you have a package loaded in your R environment, you can view the source by entering the function name to the console.

As an arbitrary example:

>> 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> 
devmacrile
  • 470
  • 2
  • 7