R:使用 = 或 <- 有什么性能差异吗?
R: Is there any performance difference between using = or <-?
例如:
a <- c(1,2,3)
或
a = c(1,2,3).
显然对于小数据框或列表来说,这根本无关紧要。我更多地考虑大数据集或在 for 循环中使用它们。
没有可衡量的性能差异;更多关于可读性和约定。 R 所做的所有计算都会成就或毁掉你。
使用<-
; "R In Action" 在第 7 页上说它是标准的,如果你不这样做,其他 R 开发人员会取笑你。
R documentation可能有更深层次的原因:
There are three different assignment operators: two of them have
leftwards and rightwards forms.
The operators <- and = assign into the environment in which they are
evaluated.
The operator <- can be used anywhere, whereas the operator = is only
allowed at the top level (e.g., in the complete expression typed at
the command prompt) or as one of the subexpressions in a braced list
of expressions.
使用您所用语言的正确习语通常是个好主意。
例如:
a <- c(1,2,3)
或
a = c(1,2,3).
显然对于小数据框或列表来说,这根本无关紧要。我更多地考虑大数据集或在 for 循环中使用它们。
没有可衡量的性能差异;更多关于可读性和约定。 R 所做的所有计算都会成就或毁掉你。
使用<-
; "R In Action" 在第 7 页上说它是标准的,如果你不这样做,其他 R 开发人员会取笑你。
R documentation可能有更深层次的原因:
There are three different assignment operators: two of them have leftwards and rightwards forms.
The operators <- and = assign into the environment in which they are evaluated.
The operator <- can be used anywhere, whereas the operator = is only allowed at the top level (e.g., in the complete expression typed at the command prompt) or as one of the subexpressions in a braced list of expressions.
使用您所用语言的正确习语通常是个好主意。