I am writing a package that contains two R files, file1.R
and file2.R
. The first file contains several function and S4 object definitions that the second file uses. I tried adding source("file1.R")
to the top of file2.R
but when I installed the library, it threw an error: cannot open file 'rgrokit.R': No such file or directory
even though the two files are located in the same directory.
How do I make the second file dependent on the first?
Edit: If I do not try to create some form of dependency, the library installation will throw an error.
Error in setMethod("foo", "bar", function(.Object, ...) { :
no existing definition for function ‘foo’
This code appears in file2.R
.
In this example, bar
is an S4 class defined in file1.R
and foo
is a method which was created using setGeneric
in file1.R