If commands are stored on an external file, say commands.R in the working directory work, they may be executed at any time in an . session with the command
source("commands.R")
For Macintosh and Windows Source is also available on the File menu. The function sink,
sink("record.lis")
will divert all subsequent output from the terminal to an external file, record.lis. The command
sink()
restores it to the terminal once again.