2

I have read past SO questions about this and their example as to why we need to use <- not = does not seem applicable (at least in the recent versions).

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

median(x <- 1:10)
x   

I always use =, BUT seem to finally found a case where <- is necessary but don't understand why, can anyone tell me why <- is necessary here and = does not work. Thank you.

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
Community
  • 1
  • 1
Benzle
  • 373
  • 3
  • 8
  • 17

0 Answers0