1

I want my R code to be organised into different files. I have done done that but I am not able to call a function present in another file from my current file. I know it would be a simple thing... It would be great if someone can pen down a response.

file1: test1.R contains

`func1<-function(){
    ....
}`

file2: test2.R contains

func2<-function(){
    func1();
}

Both files are in same directory I get an error : func1 doesn't exist

Is there something like C,Cpp like include statement in R

BenMorel
  • 34,448
  • 50
  • 182
  • 322

1 Answers1

4

You are after source:

source("func1.R")

The functions in that file should now appear in your workspace:

ls()
csgillespie
  • 59,189
  • 14
  • 150
  • 185