R< - 或=运算符,为什么< - 在这种情况下是必要的?

时间:2014-10-09 01:28:42

标签: r operators

我已阅读past SO questions about this及其示例,了解我们为何需要使用< - not =似乎不适用(至少在最近的版本中)。

median(x = 1:10)  # Should give an error but both work just fine.
x   

median(x <- 1:10)
x   

我总是使用=,但似乎最终找到了一个案例,其中&lt; - 是必要的,但不明白为什么,任何人都可以告诉我为什么&lt; - 在这里是必要的并且=不起作用。谢谢。

x=c(2,4,6)
names(x)=c('a','b','c')
x

# OR we can do this, but it requires a <-

x='names<-'(x, value=c('a','b','d'))
x='names='(x, value=c('a','b','d'))   #Error: could not find function "names="
x

0 个答案:

没有答案
相关问题