[R] how to view source code of a function inside a package?
Duncan Murdoch
murdoch.duncan at gmail.com
Thu Nov 15 20:35:51 CET 2012
On 15/11/2012 2:21 PM, C W wrote:
> Dear list,
> I am trying to look at the function inside a package. I know that
> methods() would do the trick, but what if the function is hidden? I have a
> problem displaying the hidden function.
>
> Say, for example the MCMC package. How do you view the code of that
> function?
You can use the prefix MCMC:::foo to display the foo function from MCMC,
whether or not it is exported.
Duncan Murdoch
>
> something like this:
>
> > which
>
> function (x, arr.ind = FALSE, useNames = TRUE)
>
> {
>
> wh <- .Internal(which(x))
>
> if (arr.ind && !is.null(d <- dim(x)))
>
> arrayInd(wh, d, dimnames(x), useNames = useNames)
>
> else wh
>
> }
>
> <bytecode: 0x1021eef50>
>
> <environment: namespace:base>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list