ResearchinR logo3Trans

R: Save user made functions

Creating functions in R is easy but copying the full function from one document to another is sub-optimal. You can save your functions a number of ways, my preference is as follows:

First create your function:

my_new_function <- function(x){
  do useful stuff here

Then save the function to your working directory:

save("my_new_function", file="new_function.Rdata")

You can then load your new function easily using load()


Note: You can specify the full file path when loading a function if you are not currently set to your default working directory.


Add comment

Security code