Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: Further understanding on the .Internal function

Tags:

r

I have read the description but i am still confuse by the role of the .Internal function. Because it works fine with .Internal(body(mean))but not with .Internal(mean). I presume that this is written in c++ and is compiled, but it is possible to see the code? In what folder of the R folder is?

Thanks in advance

like image 354
donpresente Avatar asked May 03 '16 20:05

donpresente


People also ask

How do I view a function within an R package?

We can find the functions inside a package by using lsf.

What is an internal function in R?

What is an internal function? It's a function that lives in your package, but that isn't surfaced to the user. You could also call it unexported function or helper function; as opposed to exported functions and user-facing functions. For instance, in the usethis package there's a. base_and_recommended()

How do you call a function from a package in R?

Every time you start a new R session you'll need to load the packages/libraries that contain functions you want to use, using either library() or require() . If you load a package with the same function name as in another package, you can use packageName::functionName() to call the function directly.


1 Answers

You can view the c source code with this:

pryr::show_c_source(.Internal(mean()))

From @Dominic Comtois post here, "the show_c_source function will search on GitHub for the relevant piece of code in the C source files. Works for .Internal and .Primitive functions."

like image 114
Adam Birenbaum Avatar answered Oct 07 '22 01:10

Adam Birenbaum