When R starts it executes the function .First in ~/.Rprofile (if it exists).
Similarly, R executes the function .Last in the same file at the end of any R.
Here's an example of how to customize your R environment:
1
2
print(pi) # prints 3.14159265358979 thanks to options in ~/.Rprofile