我想知道任务如何用R语进行。
审议以下R shell 会话:
> x <- c(5, 6, 7)
> x[1] <- 10
> x
[1] 10 6 7
>
which I totally understand. The vector (5, 6, 7) is created and bound to the symbol x . Later, x is rebound to the new vector (10, 6, 7) because vectors are immutable data structures.
但这里会发生什么:
> c(4, 5, 6)[1] <- 10
Error in c(4, 5, 6)[1] <- 10 :
target of assignment expands to non-language object
>
此处或此处:
> f <- function() c(4, 5, 6)
> f()[1] <- 10
Error in f()[1] <- 10 : invalid (NULL) left side of assignment
>
在我看来,人们只能将数值分配给指定数据结构(如xx)。
The reason why I am asking is because I try to implement the R language core and I am unsure how to deal with such assignments.
提前感谢