Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R .Internal for Beginners

Tags:

r

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

like image 713
Simon Avatar asked Jul 29 '11 14:07

Simon


People also ask

Is R easy for beginners?

Python and R are both free, open-source languages that can run on Windows, macOS, and Linux. Both can handle just about any data analysis task, and both are considered relatively easy languages to learn, especially for beginners.

Can I learn R without programming background?

Yes. At Dataquest, we've had many learners start with no coding experience and go on to get jobs as data analysts, data scientists, and data engineers. R is a great language for programming beginners to learn, and you don't need any prior experience with code to pick it up.


2 Answers

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.

like image 145
Joshua Ulrich Avatar answered Nov 07 '22 09:11

Joshua Ulrich


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

like image 27
John Avatar answered Nov 07 '22 10:11

John