2013-03-22 179 views
3

我正在試圖查看源代碼。例如cook.distance()。這是我曾嘗試如何查看R的源代碼

cooks.distance 
function (model, ...) 
UseMethod("cooks.distance") 
<bytecode: 0x3f25b5c> 
<environment: namespace:stats> 

然後我想:

debug(cooks.distance) 

,並沒有什麼。然後我想:

methods(cooks.distance) 
[1] cooks.distance.glm* cooks.distance.lm* 

Non-visible functions are asterisked 

然後我想:

lm:::cooks.distance.default 
Error in loadNamespace(name) : there is no package called ‘lm’ 

有人告訴我LM是在大衆包,所以我嘗試了以下內容:

MASS:::cooks.distance.default 
Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : 
object 'cooks.distance.default' not found 

我如何可以查看源碼?我試圖查看源代碼但找不到函數?

+1

看起來像它在'stats'包,不'MASS'。試試'stats ::: cooks.distance.lm'。 – joran 2013-03-22 20:14:37

+2

'getAnywhere(cooks.distance.lm)' – Roland 2013-03-22 20:18:42

+0

謝謝他們都做到了 – user1871528 2013-03-22 20:32:49

回答