Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view R's source code (pre-parsing)

Tags:

r

Embarrassingly basic question.

When wanting to understand R's source code I will often just write its name in R and read through the code. The downside of this method is that I will get the code with its comment stripped away.

Assuming I use git, and not subversion, what simple solutions do I have to view the source code?

For example, can I download the R's source code through git? (as in with github)

Is there some website with all of the code easily searchable?

Thanks.

like image 512
Tal Galili Avatar asked Aug 09 '12 14:08

Tal Galili


People also ask

How do I view the source code of an R package?

Compiled code built into the R interpreter. If you want to view the code built-in to the R interpreter, you will need to download/unpack the R sources; or you can view the sources online via the R Subversion repository or Winston Chang's github mirror.

Where is R source code?

All R code in packages is kept in R/ . In addition if the package is using roxygen the source code will also contain roxygen comments ( #' ) with the function level documentation. If a package is not using roxygen (often older packages or those in base R) the documentation will be in . Rd files in the man/ directory.

How do I view a function in R?

A shortcut in R Studio is to put the cursor on the function name and press F2 .


1 Answers

To download the current R-development svn using git-svn (you might need to install git-svn in addition to git):

git svn clone https://svn.r-project.org/R/trunk/

To browse R-project source code online, just visit the same site:

https://svn.r-project.org/R/trunk/

Or, for the other branches:

https://svn.r-project.org/R/

To search for, say, glm() related code in the R-development source code, I usually try a Google search:

glm site:svn.r-project.org/R/trunk/
like image 94
jthetzel Avatar answered Oct 05 '22 20:10

jthetzel