Skip to content

Latest commit

 

History

History
27 lines (16 loc) · 1.42 KB

File metadata and controls

27 lines (16 loc) · 1.42 KB

Runnable scripts

A few people were not quite sure how to make a runnable script in R.

Essentially a runnable script is just a plain text file with your code in it. You will learn (once you use Python) that the first line for many scripts is special, but you don't need to worry about that for the next few weeks

So essentially a flat text file (a file with no special formatting as one finds in .docx, or .rtf) with a ".R" extension is what you want. FYI. Common flat file formats are .txt, .csv, .tsv.

How to make a script.

Well you need to use a script editor or plain text editor (like notepad in windows, textwrangler on a Mac, gedit in linux, or nano in UNIX). HOWEVER all R integrated development environments (IDE) like the R GUIs (graphical user interface) for mac, windows or the R-Studio IDE have one built in. Good ones have syntax highlighting (i.e colour your code for different aspects of what you are writing).

##In R-studio go to File > New File > R Script.

A new empty window appears

You can type your commands in this window, and then save the file. It should save with a ".R" extension.

In the R GUI for Mac OSX

go to File > New Document A new window appears

You can type your commands in this window, and then save the file. Make sure to save with a ".R" extension.

Windows

I don't have a windows machine, but I am sure it is the same basic idea.