Loop program with commands to other programs

I have these lines of code in one program:

source("R:/ML NC8 MENSAL.R")

source("R:/ ML NPC NC8 MENSAL.R")

The mentioned programs both have these lines of code:

# Defining Variable

MONTH <- "01_2021"

I want to make this definition in the first program for the two programs.

The idea is when I run the "super program" with the source is to define the month in the "sourced" programs. This means instead of changing the month in 23 programs (or 23 times) change it only in one (or once).

Which code should I write?

Thank you for your help.

Put this in a separate script constants.R and source it from the programs that reference it.

1 Like


And in the programs which code should I write?

This one:


or this one:

MONTH <- source("R:/constants.R")

or another one?

Thank you for your help.

This will bring the constants defined in the source file into the global environment.

1 Like

Thank you @technocrat !

It worked!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.