How to Start an R Project

March 13, 2017

(This article was first published on R Language in Datazar Blog on Medium, and kindly contributed to R-bloggers)

R is the most widely used programming language in data analysis and data mining. When you first get started with R it can get a little but intimidating if you are a newbie, and sometimes even for statistics pros as the syntax can be a little bit new.

There are several ways you can access R. You can install it to your Mac, PC or Linux machine and run it from the terminal. There are also various clients you can install to assist you with the user experience.

Datazar, on the other hand, offers a cloud based client for R. Meaning you can use R right in your browser and analyze data, create charts, use packages and share your results.

Creating the Project

Project Creation Popup

Once logged in to Datazar, click on the “New Project” button on top right corner and fill out the popup with your project name. When finished hit “Create Project” and you’re done! You have created your project.

Selecting an R Interface

Now you have a choice between two R interfaces: the R console and the R notebook. Both are equally useful and it really all comes down to the preferences.

Let’s go with the R console for now. Click on the “R Console” button. This will take you to your freshly created R Console. It resembles a terminal a little bit and has a text input field at the bottom.

R Console

And there you have it. This is your portal to R and it’s crazy-awesome functionality. Let’s test it out with a quick hello world message command.

> message("Hello World")

R comes with datasets already included in the core program. So let’s use the famous iris dataset and play around with it. We’ll run two commands as below:

> iris
> head(iris)

The first command will return the entire dataset and the second command will return the first part of the dataset.

The R Console has command history support so you can use your keyboard arrows to navigate to your previous commands.

Now let’s look at graphics. The R console will return the graphics in-line with the text instead of a separate window as in the terminal. Using the console gives you a more natural feel with a little bit extra something.

Importing External Datasets

Having a very sophisticated interface is useless if you can’t use data you have collected or gathered. Let’s look at how you can use CSVs in your console.

Above the console is a button named “File.” It will show you the list of files you have in your project. Click on the checkbox that’s next to the file you want to import to your R console and click “Load Selected Files.” This ensures only the files you want in your session are loaded and keeps your workspace clean.

Let’s save the dataset to a variable called dataset:

> dataset<-read.csv("Dataset.csv")

Since this dataset is kind of long, let’s take a part of it and save it to another variable called sample:

> sample<-dataset[1:100,]

And finally plot the sample dataset:

> with(sample,plot(exper,wage,col=union))

Importing External Functions

The method for importing external functions to your R workspace is exactly the same as the method for importing datasets. Once you’ve imported the function you want from your project, use the following function to use it:

> source("customFunction.r")

This R file can be an R script that contains all your custom-reusable functions. Or even functions you copied from somewhere else.

Use External Libraries

If you want to juice up your R workspace with extra packages, all you have to do it run this function:

> library("someLibrary")

R has an infinite amount of R packages that are contributed by the community on a regular basis. Packages like ggplot2 make your R experience come to life.

R Notebook

Although we used the R console throughout this entire guide, here’s what it would have looked like if it was made with the R notebook interface.

R notebooks are very useful when you want to go back and edit code, especially if you’re working in a team and you want a more presentable format. R consoles on the other hand are great for quick, dirty explorations. Dirty because all your error and commands will be shown. Again, it’s all a personal preference.


Feel free to copy my file and play around with it:

R Console:

R Notebook:


Useful resources and documentation when using R:

CRAN Manuals

CRAN: Manuals



Datazar Blog: R Language

Datazar Blog

R Tutor: Introductions

R Introduction | R Tutorial

How to Start an R Project was originally published in Datazar Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.

To leave a comment for the author, please follow the link and comment on their blog: R Language in Datazar Blog on Medium. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)