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.
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.
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.
A shortcut in R Studio is to put the cursor on the function name and press F2 .
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/
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