Possible Duplicate:
Include files R?
I cannot find useful documentation about an R file including another R file. R is a very short word is ignored by search engines.
I have file.R and include.R and I want to do something like this:
// in include.R I want to load libraries
library(phpSerialize)
// in file.R include the previous file and use directly the given library
include(include.R)
x = rnorm(10)
y = phpSerialize(x)
Maybe you are just looking for source(file="include.R")
. Note that source()
executes the commands in the specified file, it does not (like PHP include) simply paste the contents of that file into the including file. Which is probably not important in your case.
In addition to source
, you may be interested in sys.source
. It gives you more control over the environment the file is evaluated in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With