Gabriel Pulga
Gabriel Pulga

Reputation: 293

How do I make R recognize a function that comes from another dependency within the directory?

Let's say I have a main file called main_file.R and a dependency called line_plot.R.

The line_plot.R contains a function called line_plot.

line_plot <- function(x,
                           y,
                           z,
                           w,
                           r) {(...)}

The main_file.R uses the line_plot function from within line_plot.R.

### (...)
plot_something <- line_plot(...)
### (...)

How do I make the line_plot function get recognized by the main_file is the question.

I'm getting a "could not find function" error when I run my script.

Would appreciate you guys help on this. Thank you.

Upvotes: 0

Views: 32

Answers (1)

Lennyy
Lennyy

Reputation: 6132

You should probably source the other script first, so you have that function available. Like adding source("line_plot.R") to main_file.R.

Upvotes: 1

Related Questions