Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content
Previous: Scope Next: Scalar Data Types

Input and Output Files

The following shows how to use files for running commands (input) and output:

# A sink records output to the given file.
# To print to both the screen and to a file (tee), use the following variation:
sink(file = "outputFile", split = TRUE)
source("chapter7/foo.R") # executes R code written in a text file
system("cat outputFile") # prints what was captured by the sink above
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content