[問題] 輸入錯誤格式
a <- function(n)
{
tryCatch(function1(n),
error = function(e)
{
return(NaN)
}
)
}
function1 <- function(n)
{
n^2
}
> a(s)
[1] NaN
> a(1 1)
錯誤: 未預期的 數值常數 in "a(1 1"
> a(1_1)
錯誤: 未預期的 輸入 in "a(1_"
請問如何讓a(1 1)或a(1_1)能回傳NaN?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 27.244.16.25
※ 文章網址: http://www.ptt.cc/bbs/R_Language/M.1413020993.A.64E.html
→
10/11 18:21, , 1F
10/11 18:21, 1F
→
10/11 22:50, , 2F
10/11 22:50, 2F
→
10/11 23:33, , 3F
10/11 23:33, 3F
推
10/12 13:16, , 4F
10/12 13:16, 4F
→
10/12 13:17, , 5F
10/12 13:17, 5F
→
10/12 14:16, , 6F
10/12 14:16, 6F
→
10/12 15:14, , 7F
10/12 15:14, 7F
→
10/12 15:14, , 8F
10/12 15:14, 8F
R_Language 近期熱門文章
PTT數位生活區 即時熱門文章
-1
12