2011-07-29 54 views
17

我是R新手,遇到了一些我不明白的代码。更具体地说,我想知道.Internal做什么。下面是我想转换成Matlab的一个例子:R。内部初学者

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

我想知道是什么.Internal<environment ... >做。

谢谢各位大大提前, 西蒙

+0

另请参阅http://stackoverflow.com/questions/1439348/how-to-examine-the-code-of-a-function-in-r-thats-object-class-sensitive/1444512 –

+3

对于此特定例如,知道答案只是'1 /(max-min)'可能会有帮助 –

回答

20

?.Internal

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

你会找到你的代码在R源dunif。我在main/names.c中通过grep找到这种类型的函数,然后grep查找它所指的名称(在这种情况下为do_math3),您可以在main/arithmetic.c中找到它。

<environment: namespace:stats>只是告诉你函数的位置/命名空间。

4

我找到了R in a Nutshell一个非常有用的资源,以非胁迫的方式解释对象和环境。值得一看。