How do I view source code in R? For example, for function portfolio.optim
> require(tseries)
> portfolio.optim
function (x, ...)
UseMethod("portfolio.optim")
<environment: namespace:tseries>
> methods(portfolio.optim)
[1] portfolio.optim.default* portfolio.optim.ts*
Non-visible functions are asterisked
> portfolio.optim.ts
Error: object 'portfolio.optim.ts' not found
> portfolio.optim.default
Error: object 'portfolio.optim.default' not found
When I install R package locally, does it download source code as well? Where does it store on the computer? Does anyone know?
In response to
Non-visible functions are asterisked, this means that the actual functions that are dispatched ontsor default objects, respectively, are in the tseries namespace but not exported. So just typetseries:::portfolio.optim.defaultand you see the function code once you specify the full patch including the namespace.Whether R downloads source or a binary depends on your operating system. In either event, source for the tseries package is available. Reading source code written by experienced coders is a good way to learn.