2

Following this link: http://www.r-project.org/doc/Rnews/Rnews_2006-4.pdf, I did getAnywhere() first to get the source code or rnorm()

> getAnywhere(rnorm)
A single object matching ‘rnorm’ was found
It was found in the following places
   package:stats
namespace:stats
with value

function (n, mean = 0, sd = 1) 
.External(C_rnorm, n, mean, sd)
<bytecode: 0x04b377e4>
<environment: namespace:stats>

Then I download the tar.gz file and go to /src/library/stats/src (I viewed 3.1.0 source zipped file but shouldn't matter for other Version 3 releases). But I only find Random.c, no rnorm.c or rnorm.f. I don't see rnorm.x in /src/main either.

Since this is .External, it may be a .c or .f. But where is the source or did I look at wrong function name?

  • 2
    It goes from [here](https://github.com/wch/r-source/blob/776708efe6003e36f02587ad47b2eaaaa19e2f69/src/nmath/rnorm.c) to [here](https://github.com/wch/r-source/blob/776708efe6003e36f02587ad47b2eaaaa19e2f69/src/nmath/snorm.c) – MrFlick Jun 22 '14 at 16:43
  • It is in a file called `rnorm.c` Since it is in the `stats` package you need to download the source code for functions in base `R`, i.e., functions included with the default installation. You also can display much of the information in your post with: `stats:::rnorm` – Mark Miller Jun 22 '14 at 17:08
  • Thanks for the answers. It is under /R-3.1.0/src/nmath. For some reasons, the file is not under /R-3.1.0/src/library/stats/src. I am not looking at GitHub but a downloaded zipped source. – user3078106 Jun 22 '14 at 18:07

0 Answers0