Writing a code to create an empty source R file and then run the script from that source file in my current R file

Hi

I would like to write a code in an existing R file that I am working in so that my code when executed creates a new blank source R file and saves this source file to a specific directory.

Then I would proceed to write the following commands in my newly created source R file

  1. flag <- runif(100)
  2. print(flag)

I would not execute these commands in my source R file rather just write the code .
Finally, I need to write a code in my current R file that would read all these commands from the source R file and execute in my current R file to produce the results.

Thanks in advance for your help!!

Can you motivate the desire for this seemingly purposeless level of indirection?

1 Like

This was for a college project as part of an introductory course in programming. Anyhow I was able to figure it out.

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.