2011-07-29 56 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一個非常有用的資源,以非脅迫的方式解釋對象和環境。值得一看。