R Tutorial | Introduction to R Programming – Features & Applications

1. Introduction to R Programming – Objective

In this R tutorial, we are going to learn what is R statistics, introduction to R Programming, R programming examples, r programming for data science various R software editors like RGui and R Studio and their components. Moreover, in this R tutorial, we will also learn R Features,  Applications of R programming, and how to develop R scripts with the help of examples. Also, you will get a good idea to learn R programming for data science. At last, we will discuss R script and sourcing R Script in R programming tutorial.

So, let’s start R tutorial for beginners.

R Tutorial

R Tutorial | Introduction to R Programming – Features & Applications

2. What is R Programming Language?

R language is an open source program maintained by the R core-development team. It is a team of volunteer developers from across the globe.

  • R language used for performing statistical operations
  • It is available from the R-Project website www.r-project.org.
  • R is a command line driven program.
  • The user enters commands at the prompt (> by default) and each command is executed one at a time.

Many routines have been written for R analytics by people all over the world and made freely available from the R project Website as packages. However, the basic installation (for Linux, Windows, or Mac) contains a powerful set of tools for most purposes.
R is a consolidated environment for performing statistical operations and generating R data analysis reports in graphical or text formats. R commands entered in the console are evaluated and executed. So, it cannot handle certain auto-formatting characters such as en-dashes or smart quotes; therefore, you need to be careful while copying and pasting commands into R from other applications. Let us now learn something about the history of R in this Introduction to R Programming.

3. R Tutorial – History

John Chambers and colleagues developed R at Bell Laboratories. R is an implementation of the S
programming Language and combines with lexical scoping semantics inspired by Scheme. R was named
partly after the first names of two R authors. The project conceives in 1992, with an initial version
released in 1995 and a stable beta version in 2000. Let us also understand in this Introduction to R Programming Tutorial, that Why should we learn R Programming.

4. Why Learn R Programming Language?

  • R programming language is best for statistical, data analysis and machine learning. By using this language we can create objects, functions, and packages. We can use it anywhere. It’s platform- independent, so we can apply it to all operating system. It’s free, so anyone can install it in any organization without purchasing a license.
  • R is open source. Thus, Google is utilizing R programming as it is a suitable language. By using R, we can create any form of statistics and data manipulation. Furthermore, we can use it in
    almost every field like finance, marketing, sports etc.
  • R, SAS, and SPSS are three statistical languages. Of these three statistical languages, R is the only an open source. SAS is the most important private software business in the world. SPSS is now overseen by IBM. R Programming is extensible and hence, R groups are noted for its energetic contributions. Lots of Rs typical features can be written in R itself and hence, R has gotten faster over time and serves as a glue language.

Any doubt in Introduction to R Programming? Please Comment.

5. R Tutorial – Features of R

Following features of R Programming –

R Tutorial

R Tutorial – Features of R Programming

  • It supports procedural programming with functions and object-oriented programming with
    generic functions. Procedural programming includes procedure, records, modules, and
    procedure calls. While object-oriented programming language includes class, objects, and
  • Packages are part of R programming. Hence, they are useful in collecting sets of R functions into a single unit.
  • Rs programming features include database input, exporting data, viewing data, variable labels, missing data, etc.
  • R is an interpreted language. Hence, we can access it through command line interpreter.
  • R supports matrix arithmetic.
  • It has effective data handling and storage facilities.
  • R supports a large pool of operators for performing operations on arrays and matrices.
  • It has facilities to print the reports for the analysis performed in the form of graphs either on-screen or on hardcopy.

So, we can obtain the installation files for the R program on the official R Website (www.r-project.org). The website has general documentation related to R along with the libraries of routines. We can simply download and install the R program from the R Website.

6. Comparison Of R With Other Technologies

  • Data handling Capabilities – Good data handling capabilities and options for parallel computation.
  • Availability / Cost – R is an open source and we can use it anywhere.
  • Advancement in Tool – If you are working on latest technologies, R gets latest features.
  • Ease of Learning – R has a learning curve. R is a low-level programming language. As a result, simple procedures can take long codes.
  • Job Scenario – It is a better option for start-ups and companies looking for cost efficiency.
  • Graphical capabilities – R is having the most advanced graphical capabilities. Hence, it provides you with advanced graphical capabilities.
  • Customer Service support and community – R is the biggest online growing community.

Read: Future Scope of R Programming Language

7. R Tutorial – R Scripts

It is utilized as a statistical programming environment for solving problems. R tools can also operate as a general matrix calculation toolbox.
R provides the freedom of selecting and editing tools to interact with the native console. While scripting in R, you don’t need to type commands but rather call functions to achieve results. Hence, the RConsole allows command editing.
The developed R scripts can be executed in the selected editor. So, you could download the data and save them in a local file, or just cut and paste the data from the browser to an editor such as Notepad, and then save them. The prominent editors available for R programming language are:

  • RGui (R graphical user interface)
  • Rstudio – Studio R offers a richer editing environment than RGui and makes some common tasks easier and more fun.

We will see about them in details below in this Introduction to R Programming.
Read: Why Learn R Programming

i. R Graphical User Interface (RGui)

Once you download R, RGui is provided as the standard graphical user interface (GUI). Most important component of RGui is the R console window. The console window in R is a place where instructions, scripts, and general R operations are performed. The console window also has R tools to manage the R environment. The R console screen appears every time the RGui is opened. It lists some basic information such as the R version installed and the licensing conditions.
In the RGui window, you can open a new script, go to the ‘File’ menu and select ‘New Script’. The RGui can be accessed using the menu shortcuts created during the installation process.
The R prompt, a ‘>’ symbol indicates the place where the user can enter commands. To quit an active R session, you need to type the following code in the console after the command prompt (>):
> q()
R asks a question to ensure that the user wishes to quit the active session.
Note the parentheses after the q; this is because in R you don’t type commands but rather call functions to achieve results, even quit.

ii. RStudio

RStudio is an integrated development environment (IDE) for R language. It is a code editor and development environment, with some nice features that make code development in R easy and fun.
a. Features of RStudio

  • Code highlighting that gives different colors to keywords and variables, making it easier to read
  • Automatic bracket matching
  • Code completion, so as to reduce the effort of typing the commands in full
  • Easy access to R Help, with additional features for exploring functions and parameters of functions
  • Easy exploration of variables and values. RStudio is available free of charge for Linux, Windows, and Mac devices. It can be directly accessed by clicking the RStudio icon in the menu system on the desktop.

Because RStudio is available free of charge for Linux, Windows, and Mac devices, it is a good option to use with R. To open RStudio, click the RStudio icon in the menu system or on the desktop.
b. Components of RStudio

  • Source – Top left corner of the screen contains a text editor that lets the user work with source script files. Multiple lines of code can also be entered here. Users can save R script file to disk and perform other tasks on the script.
  • Console – Bottom left corner is the R console window. The console in RStudio is identical to the console in RGui. All the interactive work of R programming is performed in this window.
  • Workspace and History – The top right corner is the R workspace and history window. This provides an overview of the workspace, where the variables created in the session along with their values can be inspected. This is also the area where the user can see a history of the commands issued in R.

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

  • Files – This is where the user can browse folders and files on a computer.
  • Plots – Now, this is where R displays the user’s plots.
  • Packages – This is where the user can view a list of all the installed packages.
  • Help – This is where you can browse the built-in Help system of R.

8. R Tutorial – Scripting in R

Let us start scripting in R.
Let’s 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!”)
We get the output as:
[1] “Hello world!”
Read: How to Install R, R Studio and R Packages in Simple Steps?

9. R Tutorial – Sourcing a Script in R

R provides the feature to develop scripts in external editors and then import in R for execution. This is known as sourcing a script. The individual line of code or a block or entire script can be sourced in R in RGUI or RStudio as below:
Multiple lines of code can be entered in the source editor without having each line evaluated by R. Once we complete the scripting, we can send the entire script to R. In other words, you can source the script
We can source the script in either Rgui or Rstudio in the following ways:
To send an individual line of code from the editor to the console:

  • In RGUI, Click the line of code and then press Ctrl+R to execute the instruction.
  • In RStudio, press Ctrl+Enter or click the Run button to execute the instruction.

So, to send a block of highlighted code to the console:

  • Select the block that needs to execute and then presses Ctrl+R in RGui or Ctrl+Enter RStudio.

To send the entire script to the console:

  • In RGui, click anywhere in the script window, and then choose EditðRun all.
  • In RStudio, click anywhere in the source editor and press Ctrl+Shift+Enter or click the Source

Only R Studio defines this keyboard shortcuts. So, in the different source editor, these options may be different.
Now we can send the entire script to the R console. To do this, click the Source button at the top right corner of the editor window or choose edit→Source. Now, the script starts to reach the point where it asks for input and then waits for the user to enter the name in the console window. Next, turn in the introduction to R Programming Language is Applications of R.

Read: Future Scope, Salary and Career Growth in R Programming

R Quiz

10. R Tutorial – Applications of R Programming

  • Many data analysts and research programmers use R because R is the most prevalent language.
    Hence, we use R as a fundamental tool for finance.
  • Many quantitative analysts use R as their programming tool. Hence, R helps in data importing
    and cleaning, depending on what manner of strategy you are using on.
  • R is best for data Science because it gives a broad variety of statistics. In addition, R provides the environment for statistical computing and design. Rather R considers as an alternate execution of S.

So, this was all about the R tutorial. Hope you like our explanation.

11. Conclusion: R Tutorial

Hence, in this R tutorial, we have studied the introduction to R programming in detail. So, it is clear from the above information that R is more popular and better option as R supports a different kind of programming
languages. Also, R is an Open source and has far more capabilities and availability to other languages. Still, if you have any doubts about the R Tutorial, please Comment.
Hope you like the Introduction to R Programming Tutorial.
See Also-

13 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.

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.