William M. Briggs

Statistician to the Stars!

R Lecture 2: Prepping a Folder

Main page for R Lectures.

This is the second in a series of lectures on R.

R is command-line software. We need to type in commands. These commands should be SAVED so they are not forgotten. Because of this, we must set up a folder and file and know where those folders and files are on our computers.

Windows Set up a folder on the “C” drive. Call it “myR”. It IS case sensitive.

Mac Set up a folder on your DESKTOP. Call it “myR”. It IS case sensitive.

Linux Set up a folder in your home path. Call it “myR”. It IS case sensitive.

Next, open a text editor. DO NOT USE MICROSOFT WORD. That software contains hidden characters that WILL interfere with R. Use Notepad or Wordpad or other text editor. If you ignore this warning you will suffer.

In the myr folder, save the file “myRcode.R”. In Windows, this might save as “myRcode.R.txt“. Windows has a nasty habit of thinking it knows what you want. If you are using Notepad or other Windows software, be sure that the type of file to save is “All files” or similar words. If you do not pay attention to me you will suffer.

Cut and paste the following block of text into your myRcode.R file and SAVE it.

x = 7
y = 8

We will cut & paste this code from the file myRcode.R into the R command window. EACH TIME REMEMBERING TO HIT THE ENTER KEY (inside R).

R can be downloaded here: R-project.org. A direct link to the CRAN package archive is here.

Next time: actual math! The next lesson will appear tomorrow.

All videos are on YouTube under the username “mattstat” (wmbriggs was taken). That service imposes a ten-minute limit of videos. Accordingly, lectures are short.

All questions to matt@wmbriggs.com.


  1. Odd lead-in from someone who yearns for the music of Strayhorn and the like.

  2. Vim (http://www.vim.org), Notepad++ (http://notepad-plus.sourceforge.net/uk/site.htm) and SciTE (http://www.scintilla.org/SciTE.html) will edit your R files and supply syntax colouring to help you get it right. You may find one of them helps.

    Myself, I use Vim but I’m not pushing it.

  3. Briggs

    January 28, 2010 at 9:27 am


    Even worse, YouTube tagged it as a copyright violation. Must mean that there’s a digital watermark in the clip.


    Vim is great. I use it all the time for remote logins.

  4. Tinn-R is another syntax-highlighting text editor that, with some fiddling, will interface with R directly (e.g., you can send code to R without copying and pasting).

  5. Briggs

    January 28, 2010 at 12:17 pm


    Tinn-R is very useful, but only works on Windows—not Mac or Linux. We’ll also learn about the source() function.

  6. OK – starting late, and I have no idea where I’ll use this, but happy to play along and see.

    First hurdle is that text edit (mac) doesn’t like me to save a file as *.R as it wants to save as .rtf other format options still add an extension. Other Options? Otherwise ready to start lecture 3.

Leave a Reply

Your email address will not be published.


© 2017 William M. Briggs

Theme by Anders NorenUp ↑