[R] Howto view function's source code of an installed package

Paul Hiemstra p.hiemstra at geo.uu.nl
Wed Jul 16 10:12:41 CEST 2008

Gundala Viswanath wrote:
> Hi,
> Is there a way I can view the functions source code of  a
> package I installed in my PC.
> For example I downloaded the great "mixtools" package.
> I want to see the source code of one of its function "normalmixEM"
> Is there a way to do it? Presumably from R command prompt?
> I tried to take a look at the zip file, but somehow I can't seem
> to find the file on which I can find the source code. Please advice.
> - Gundala Viswanath
> Jakarta - Indonesia
> ______________________________________________
> 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.

You can see the R-source code of a function if you give the command 
without the brackets. For example:

 > sort
function (x, decreasing = FALSE, ...)
    if (!is.logical(decreasing) || length(decreasing) != 1)
        stop("'decreasing' must be a length-1 logical vector.\nDid you 
intend to set 'partial'?")
<environment: namespace:base>

Another option is to download the .tar.gz source package from CRAN, 
unpack it and the R source code is available in the "R" subdirectory.


Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone: 	+31302535773
Fax:	+31302531145

More information about the R-help mailing list