2013-10-20 69 views
0

我採購我的功能nnn.R使用線路:錯誤:無法找到函數「nnn.R」

source("nnn.R")*

,並沒有得到任何錯誤,但是當我嘗試運行它,這是我所得到的:

Error: could not find function "nnn"*

enter image description here

這一切是什麼函數裏面

函數(x)is.null(x)

+3

nnn是一個文件,而不是一個函數。你需要在「nnn.r」文件中創建一個函數來使用它:'myfun < - function(x){doin'stuff with x}''source'命令只讀取你在別處寫過的行;它不像MATLAB那樣工作。你可能想要將介紹掃描到R,特別是這個部分:http://cran.r-project.org/doc/manuals/R-intro.html#Writing-your-own-functions – Frank

+1

哦,我明白了,這工作 nnn < - function(x){is.null(x)} 非常感謝你 – Musmar

回答

1

nnn.R是一個文件,而不是函數。該文件必須包含一個函數,定義爲:

nnn <- function(x) { 
    return (is.null(x)) 
} 

注意nnn.R可能包含幾個函數定義。參見例如this tutorial

+0

雖然這裏給出的函數定義可能不會是你想要的。 – Dason

+0

謝謝你的幫助 – Musmar

相關問題