1 min read

R closure

R 中_function_也可以是一種物件型態,或稱做叫作_closure_:

> typeof(rnorm)
[1] "closure"

要比較兩個function物件,則可透過body這個函數:

> body(rnorm) == body(rexp)
[1] FALSE
> body(rnorm) == body(temp)
[1] TRUE