Wednesday, October 16, 2013

Getting Started with R ( simple first 5 steps)

Here are a few steps that can get you started with R. This is assuming you have installed R on your computer. If you haven't, download it from here (

Before you do anything else, you need to define the working directory for R. By default, R will have its own working directory. It is a good idea to change the working  directory based on the project you are working on.

1. Check the current working directory:
> getwd()

 Change the current working directory:
> setwd(C:\Users\ABC)

Note: Notice the type of slashes used in writing the directory. Using a different slash is a common issue.

2. Load your data file:
1. Although you can load your file in various formats, I would recommend creating a csv file format of your data.
2. Place the file in the working directory. You can place it anywhere else on the computer as well but in that case, you have to enter the full location of the file.

> a = read.csv("file.csv")

This is assigning the name 'a' for your file in R.

3. Get column names:

> names(a)

4. Know the data type (gives you the structure of your dataset):

> str(a)

5. Summary of the dataset:

> summary(a) 

At any point, if you feel the need of knowing more about the command you are using, you can use help in R.
> ?command
e.g. > ?read.csv


  1. Yes- I always loved statistics. This is basic stuff.
    My MBA has a concentration in Business Analytics.

  2. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work... 메이저놀이터