Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

By Gabriel Vasconcelos

## R functions

The book Advanced R, by Hadley Wickham, shows a very interesting statement:

“To understand R, two slogans are Helpful:

• Everything that exists in an object.
• Everything that happens is a function call.”

– John Chambers

In other words, every action is caused by a function, and functions are things you can change. [, ( and + are all functions. That means you can call these actions as functions.

> a=1:10

> #Two equivalent codes
> [(a,4)
[1] 4

> a[4]
[1] 4

> #Other two equivalent codes
> +(3,7)
[1] 10

> 3+7
[1] 10


## Just a little prank

Imagine you want to do a little prank with your friend who left his R oppened in the office. You could change the + function like in the code below and see the magic happens.

> +=function(x,y)x-y
> 1+1
[1] 0