I am using an R script that someone sent me. This is not a big package but just one function. To use it, I source the file.
However,whenever I restart R, I must type in source("directory") again to use the function.
Is there any way I can avoid this and set that function permanently?
I think that you just want to add
source("directory")to your .Rprofile so that the function gets loaded at startup.See this SO question for some handy things you can do with .Rprofile.