Getting Started

Start out by installing R. Just go to The R Website and click on the installer to download and install the version for your operating system.

Here are a couple of commands to get you started. You will want to be able to load data into R, so save it from your spreadsheet program in comma-delimited text format. Start R by double-clicking its icon. Use the following commands to get around:

getwd() will tell you the current working directory.

setwd() will allow you to set the working directory: setwd(“C:/Users/ajones/Rexamples”).

list.files() lists the files in the current working directory.

mydata <- read.csv(“myfile.csv”) loads the information in “myfile.csv” into a data frame called “mydata”. Of course, the name (mydata) can be whatever you want, and the file could have any name.

After you load your data, you can type just the data frame name to see the contents of
the file you’ve loaded. This step is usually a good idea to make sure the data loaded properly.

head() will show you just the first few lines of the data frame. Type head(mydata), for example.