17

I am new to R and I ran into a piece of code that I do not understand. More specifically, I would like to know what .Internal does. Here is an example that I am trying to convert to Matlab:

dunif <- function (x, min = 0, max = 1, log = FALSE) 
.Internal(dunif(x, min, max, log))
<environment: namespace:stats>

I would like to know what .Internal and <environment ... > do.

Thank you much in advance, Simon

Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418
Simon
  • 171
  • 1
  • 3

2 Answers2

20

From ?.Internal:

 ‘.Internal’ performs a call to an internal code which is built in
 to the R interpreter.

You'll find the code for dunif in the R sources. I find this type of function via a grep for it in main/names.c then grep for the name it refers to (do_math3 in this case), which you will find in main/arithmetic.c.

<environment: namespace:stats> simply tells you the location / namespace of the function.

Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418
4

I found R in a Nutshell a useful resource to explain objects and environments in a non-intimidating way. It is worth a look.

John
  • 41,131
  • 31
  • 82
  • 106