A script is a good way to keep track of what you're doing. If you have a long analysis, and you want to be able to recreate it later, a good idea is to type it into a script. If you're working in the Windows R GUI (also in the Mac R GUI), there is even a built-in script editor.
|Photo credit: Srini|
- You can prepare a script in any text editor, such as vim, TextWrangler, or Notepad.
- You can also prepare a script in a word processor, like Word, Writer, TextEdit, or WordPad, PROVIDED you save the script in plain text (ASCII) format.
- This should (!) append a ".txt" file extension to the file.
- Drop the script into your working directory, and then read it into R using the source() function.
- Just put the .txt file into your working directory
- Now that you've got it in your working directory one way or another, do this in R.