1

I have stumbled apon this code:

colnames(dataFrame) <- c("firstCol", "secondCol")

which renames columns of given dataframe dataFrame. What is happening there? How can I possibly assign something to return value?

Corresponding R-fiddle

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
Filip
  • 386
  • 6
  • 16

1 Answers1

1

Example 1:

> `setvalue<-` <- function(x,value) value
> x <- 0
> setvalue(x) <- 1
> x
[1] 1

Example 2:

> `add<-` <- function(x,value) x+value
> x
[1] 1
> add(x) <- 3      # x <- x+3
> x
[1] 4
chan1142
  • 609
  • 4
  • 13