How to make R includes

Possible duplicate:
Include R files?

I can not find useful documentation about the R file, including the other R file. R is a very short word that is ignored by search engines.

I have a .R file 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)
+3
source share
2 answers

Perhaps you are just looking source(file="include.R"). Please note that it source()executes commands in the specified file, and not (for example, PHP include) simply inserts the contents of this file into the included file. Which is probably not important in your case.

+17
source

source sys.source. , .

+2

Source: https://habr.com/ru/post/1778072/


All Articles