3 回答

TA貢獻(xiàn)2003條經(jīng)驗(yàn) 獲得超2個(gè)贊
<<-
power
square
cube
power <- function(exponent) { function(x) x ^ exponent}square <- power(2)square(2) # -> [1] 4square(4) # -> [1] 16cube <- power(3)cube(2) # -> [1] 8cube(4) # -> [1] 64
<<-
<-
new_counter
i
new_counter <- function() { i <- 0 function() { # do something useful, then ... i <<- i + 1 i }}
counter_one
counter_two
counter_one <- new_counter()counter_two <- new_counter()counter_one() # -> [1] 1counter_one() # -> [1] 2counter_two() # -> [1] 1

TA貢獻(xiàn)2021條經(jīng)驗(yàn) 獲得超8個(gè)贊
<<-
assign
inherits
TRUE
assign
assign
<<-
<<-
assign(x, value, inherits=TRUE)
search
).
apply
<<-
- 3 回答
- 0 關(guān)注
- 671 瀏覽
添加回答
舉報(bào)