Is there an easy way to view the source of an R package (or a method in a package), from within the interactive environment?
To view all the contents of a defined object, use the View() function. Behind the scenes, the R calls utils::View() on the input and returns it invisibly. If the input is not a data frame, it is processed using a variant of as. data.
A source package is just a directory of files with a specific structure. It includes particular components, such as a DESCRIPTION file, an R/ directory containing . R files, and so on.
Just enter the name of a function/method without parentheses:
R> base::rev.default function (x) if (length(x)) x[length(x):1L] else x <environment: namespace:base>
See also R-Help Desk - Accessing the Sources in R News Volume 6/4, October 2006.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With