Reputation:
So I have code for a custom function in R, e.g. simply:
f <- function(x) return(x)
What I want to do is be able to call this function f
as if it came with default R. That is, I don't want to have to source()
the file containing the code to be able to use the function. Is there a way to accomplish this?
Upvotes: 1
Views: 105
Reputation: 193517
What you are looking to do is documented extensively under ?Startup
. Basically, you need to customize your Rprofile.site
or .Rprofile
to include the functions that you want available on startup. A simple guide can be found at the Quick-R site.
One thing to note: if you are commonly sharing code with others, you do need to remember what you've changed in your startup options and be sure that the relevant functions are also shared.
Upvotes: 3