R Tutorial – Be a Data Science rock star with R

Today, we are starting a tour of the R programming language in which we will explore its different and essential concepts. This R DataFlair Tutorial Series is designed to help beginners to get started with R and experienced to brush up their R programming skills and gain perfection in the language.

R is one of the most widely used programming languages for statistical modeling. It has become the lingua franca of Data Science. In this article, we will provide you with the introduction to R programming language, its examples and we will also see how R is transforming the Data Science industry. We will also go through the various editors, environments through which you can run the R code.


Let’s quickly begin the R tutorial.

Stay updated with latest technology trends
Join DataFlair on Telegram!!

What is R Programming Language?

R is an open-source programming language that facilitates statistical computing and graphical libraries. Being open-source, R enjoys community support of avid developers who work on releasing new packages, updating R and making it a steadfast programming package for Data Science.   

  • With the help of R, one can perform various statistical operations.
  • You can obtain it for free from the website www.r-project.org.
  • It is driven by command lines.
  • Each command is executed when the user enters them into the prompt.

Since R is open-source, most of its routines and procedures have been developed by programmers all over the world. All the packages are available for free at the R project website called CRAN. It contains over 10,000 packages in R. The basic installation comprises of a set of tools that various data scientists and statisticians use for multiple tasks.

In R, there is a comprehensive environment that facilitates the performance of statistical operations as well as the generation of data analysis in graphical or text format. The commands that a console takes in as input are assessed and subsequently executed. R is incapable of handling auto-formatting characters such as dashes or quotes, hence, you need to be discreet while copy-pasting commands from external sources into your R environment.

Do you know – How to Install Packages in R programming

History of R

R was conceived at the Bell Laboratories by John Chambers in 1976. R was developed as an extension as well as an implementation of S programming language.

The R project was developed by Ross Ihaka and Robert Gentleman and released in 1992, its first version in 1995 and a stable beta version in the year 2000.

After seeing the history in this R tutorial, now, let’s move on to the reasons for learning R programming.

Why Learn R Programming Language

  • With R, you can perform statistical analysis, data analysis as well as machine learning. We can create objects, functions and packages in it. R is platform-independent and can be used across multiple operating systems. R is free owing to its open-source GNU licensing and can be installed by anyone.
  • R consists of a robust and aesthetic collection of graphical libraries like ggplot2, plotly and many more. With these libraries, you can make visually appealing and elegant visualisations. 
  • R is most widely used by the various industries. Only the academic avenues in the past made use of R but industries are now using R as their primary tool for statistical modeling. The most profound industry that makes use of R is the Data Science industry and the several underlying industries that it comprises of. industries like health, finance, banking, manufacturing and many more.
  • There are about 2 million job openings for R programmers worldwide. Companies hire R programmers for many roles like data analysts, business analysts, data visualization experts, and business intelligence experts.

Discover other essential reasons to learn R Programming

Features of R Programming

Now it’s time to discuss the features of R Programming:

  • R is a comprehensive programming language that provides support for procedural programming involving functions as well as object-oriented programming with generic functions.
  • There are more than 10,000 packages in the repository of R programming. With these packages, one can make use of functions to facilitate easier programming.
  • Being an interpreter based language, R produces a machine-independent code that is portable in nature. Furthermore, it facilitates easy debugging of errors in the code.
  • R facilitates complex operations with vectors, arrays, data frames as well as other data objects that have varying sizes. 
  • R can be easily integrated with many other technologies and frameworks like Hadoop and HDFS. It can also integrate with other programming languages like C, C++, Python, Java, FORTRAN, and JavaScript.
  • R provides robust facilities for data handling and storage.
  • As discussed in the above section, R has extensive community support that provides technical assistance, seminars and several boot camps to get you started with R.
  • R is cross-platform compatible. R packages can be installed and used on any OS in any software environment without any changes.

How R is better than Other Technologies

There are certain unique aspects of R programming which makes it better in comparison with other technologies:

  • Graphical Libraries – R stays ahead of the curve through its aesthetic graphical libraries. Libraries like ggplot2, plotly facilitate appealing libraries for making well-defined plots.
  • Availability / Cost – R is completely free to use which means widespread availability.
  • Advancement in Tool – R supports various advanced tools and features that allow you to build robust statistical models.
  • Job Scenario – As stated above, R is the primary tool for Data Science. With the immense growth in Data Science and rise in demand, R has become the most in-demand programming language of the world today.
  • Customer Service Support and Community – With R, you can enjoy strong community support.
  • Portability – R is highly portable. Many different programming languages and software frameworks can easily combine with the R environment for the best results.

You must definitely check the R vs Python for Data Science

R Scripts

R is the primary statistical programming language for performing modeling and graphical tasks. With its extensive support for performing matrix computation, R is used for a variety of tasks that involve complex datasets.

There is the entropy of freedom for carrying out the selection of editing tools to perform an interaction with the native console. In order to perform scripting in R, you can simply import packages and then use the provided functions to achieve results with minimal lines of code.

There are several editors and IDEs that facilitate GUI features for executing R scripts. Some of the useful editors that support the R programming language are:

  • RGui (R Graphical User Interface)
  • Rstudio – It is a comprehensive environment for R scripting and has more features than Rstudio.

1. R Graphical User Interface (R GUI)

R GUI is the standard GUI platform for working in R. The R Console Window forms an essential part of the R GUI. In this window, we input various instructions, scripts and several other important operations. This console window has several tools embedded in it to facilitate ease of operations. This console appears whenever we access the R GUI.

In the main panel of R GUI, go to the ‘File‘ menu and select the ‘New Script‘ option. This will create a new script in R.

In order to quit the active R session, you can type the following code after the R prompt ‘>’ as follows:

> q()

2. RStudio

RStudio is an integrated and comprehensive Integrated Development Environment for R. It facilitates extensive code editing, development as well as various features that make R an easy language to implement.

Before proceeding ahead in R tutorial, please confirm, have you checked – Importing Data in RStudio

Features of RStudio

  • RStudio provides various tools and features that allow you to boost your code productivity.
  • It can also be accessed over the web and is cross-platform in nature.
  • It facilitates automatic checking of updates so that you don’t have to check for them manually.
  • It provides support for recovery in case of file loss.
  • With RStudio, you can manage the data more efficiently.

Components of RStudio

  • Source – In the top left corner of the screen is the text editor that allows you to work within source scripting. You can enter multiple lines in this source. Furthermore, users can save the R scripts to files that are stored in local memory.
  • Console – This is present on the bottom left corner of the main window of R Studio. It facilitates interactive scripting in R.
  • Workspace and History – In the top right corner, you will find the R workspace and the history window. This will give you the list of all the variables that were created in the environment session. Furthermore, you can also view the list of past commands that were executed by R.

Files, Plots, Package, and Help at the bottom right corner gives access to the following tools:

  • Files – A user can browse the various files and folders on a computer.
  • Plots – We obtain the user plots here.
  • Packages – Here, we can view the list of all the installed packages.
  • Help – We can browse the built-in help system of R with this command.

Scripting in R

Let’s start scripting in R.

We will create a script to print “Hello world!” in R. To create scripts in R, you need to perform the following steps:

Here in R, you will have to enclose some commands in print() to get the same output as on the command line. So you need to type below command: This takes “Hello World” as input in R.

print("Hello World")  #Author DataFlair

Sourcing a Script in R

While R console provides an interactive method to perform R programming, R Studio also provides various features to develop a script in the external editors and source the script into the console. You can source either selected lines or the entire code using R GUI and R Studio.

An advantage of writing into the R editor is that multiple lines can be written at once without prompting R to evaluate them individually. You can source the script in the following ways:

In order to execute a selected line of code:

Select the line(s) of code, then press Ctrl + R in R GUI and Ctrl + Enter in RStudio. For example, we have two lines of code as follows:


In the above code, if you only want to print “Hello”, then select only the first line and press Ctrl + Enter in RStudio.

In order to execute the entire script:


  • Go to Edit, and then click Run All.

In the case of R Studio,

  • Hold and press Ctrl+Shift+ Enter.

Companies Using R

Some of the companies that are using R programming are as follows:

  • Facebook
  • Google
  • Linkedin
  • IBM
  • Twitter
  • Uber
  • Airbnb
  • Ford Motor company
  • Microsoft

Applications of R Programming

  • R is used in finance and banking sectors for detecting fraud, reducing customer churn rate and for making future decisions.
  • R is also used by bioinformatics to analyse strands of genetic sequences, for performing drug discovery and also in computational neuroscience.
  • R is used in social media analysis to discover potential customers in online advertising. Companies also use social media information to analyse customer sentiments for making their products better.
  • E-Commerce companies make use of R to analyse the purchases made by the customers as well as their feedbacks.
  • Manufacturing companies use R to analyze customer feedback. They also use it to predict future demand to adjust their manufacturing speeds and maximize profits.

After completing the R tutorial, get to know about the Different Applications of R Programming in detail


In the above article of R tutorial, we discussed about the R programming and its basic information. R has become a standard name in the world of programming. It is the most used tool in Data Science and many users are opting R due to its useful advantages and features. Its open-source nature makes R a much better choice for many Data Scientists.

Any queries or feedback related to the R tutorial? Share your views in the comment second. Our experts at DataFlair will be happy to help you.

Did you like our efforts? If Yes, please give DataFlair 5 Stars on Google | Facebook

26 Responses

  1. Sam says:

    I constantly spent my half an hour to read this web site’s posts daily. This is an awesum article on introduction to R programming language.

    • Data Flair says:

      Sam, you are just fabulous. Thank you for visiting Data Flair and spending time on it. There are more such articles on R Programming Language, you can check them on our site.
      Your review of R Programming Language is so motivating for us.
      Keep visiting Data Flair

  2. birhanu says:

    martix operations with its formation

  3. Shahriar Islam says:

    I am interested about R but don’t know how can I start?

    • Nivi.V says:

      i like to study rprogramming,but i dono where to study.seeking for a good website

      • Data Flair says:

        Hii Nivi,
        Hope our article on R Programming Language helped you to clear some of your concepts on R. As I explained to Shahriar, you can also check our website for more R learning. There is much more to learn about R and we have shared that learning material with everyone. You can start your R learning with this link
        Share your experience of reading the blog with us. So that, we can offer you more on R.
        Thank you for visiting Data Flair

    • Data Flair says:

      Hii Shahriar,
      Thank you, for asking the query about R.
      You can start your journey of R Programming Language with us. We have published the complete tutorial for R Programming Language on our website. Go through all the published blogs and follow all the given links to get the better understanding of R.
      Still, while learning R if you feel any hurdle, you can freely ask the query with us. We will definitely help you.

  4. Veeresh Rampur says:

    Very lucid explanation. The beneficial part is R is open source, licence free software. Its platform free. Very informative.

  5. Emma kalondu says:

    Great work

    • Data Flair says:

      Hello Emma,
      Very glad to see your review on R programming. Our readers feedback always motivate us to publish more blogs. If you want to learn any other topic in R, you can freely tell us.
      Keep visiting Data Flair.

  6. Suraj says:

    Thanks for providing all these details in a compact form. This is the best R tutorial for beginners

    • DataFlair Team says:

      Hi Suraj,
      We are enthralled that you liked our R programming Tutorial. Nice feedback from our loyal readers like this always motivates us to work harder, so that we can provide you with more great stuff.
      Keep connected with us for more R tutorials.

  7. Srinu says:

    Hi DataFlair Team,

    This is one of the best R programming tutorial. I have gone through all the topic and practiced more.
    can you please suggest where can i get real time scenario using R.

    • DataFlair Team says:

      Hello Srinu,
      Thanks for connecting DataFlair. R is a beautiful language and highly used in Data Science. You can learn R easily, just refer our sidebar and complete all the R tutorials from top to bottom.
      Hope, it helps!

  8. Mike030386 says:

    I find this tutorial very informative. I have just started learning R programming on my own, and the introduction, so far, considering all the books I have read, is the best. An overview which gives you a picture of what R programming is and at the same time gives you an actual practice. It’s like it’s not only giving me information but also it walks me through the process. Keep up!

    Should I get stuck in some areas while learning this. I’ll let you know. Thank you for this. =)

  9. Krish says:

    It is essential to learn any programming language before learning R?

    • DataFlair Team says:

      Hi Krish,
      No, it is not necessary. You can choose R to start your career. Learn R from DataFlair, we have a more than 100 R tutorials from beginners to experienced. Start from the Introduction to R and towards the end, you will be able to implement your own Data Science project in R.

  10. Akshay says:

    hello sir today i saw your blog first time it is fantastic. you give good information in concise way.
    I want to know you provide the video of R programming or not?

    • DataFlair Team says:

      Hey Akshay,
      Thanks for the appreciation. DataFlair is an online platform providing free tutorial series for everyone from beginners to experts. Soon, we will work on video tutorials as well. Till then, please refer to our R tutorial series.

  11. Srinivasa K says:


    I want learn learn R programming, but i don’t know where to start please suggest me or share me details in my whatsapp +91 8971091331

    • DataFlair Team says:

      You can refer to the sidebar and learn the R concepts sequentially. All the R tutorials are designed from a beginner’s perspective in an easy to understand language.

  12. Shorai Dzimati says:

    This is a well structured and simplified learning platform for R. Well done DataFlair Team, keep it up. I have recently started my journey to learn R towards a professional transition from being a Data Engineer to a Data Scientist.

  13. Malachi Kaselchumfa says:

    I just started learning R Programming and I believe it’s one of the best decision I have made in recent times. I hope to get as much knowledge that I can to help me in my data science journey.

  14. Julie Lin says:

    HI Data Flair,

    I just wanted to let you know you did a great job on making it easy to understand even for people like me who are coming from a business & sales background. The sitemap gave me a overall idea about what are covered and with no fear of learning them because your make it very digestible! Thank you for providing such a great website and sharing the information to help people who want to advance their careers!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.