How to start working with R


 Start working with R programing

How to run program in R | How to take input from users in R | How to program in R | Basics of R programming language | How to make comments in R programming language | How Indicators works in R programming | R Basic programming

Hello fiends,

Today we are going to learn how to start working with in the R programing, so it will easy for you to understand that how to start working with the R programming and how to start the simple programs because basics makes strong structure in future. Here we will learn today :

  • How to run a program in R
  • How to take input from user in R
  • How to make comment in R
  • How to declare variable here in R

before start just understand to use indicators first.

In other programming languages we are indicators to declare some values with the sign of “=”, but in R there are some changes. Instead of “=” here we are using “<-” symbol.

Well we can also use “=” symbol to declare but the professionalism shown by “<-” symbol.

As well as we can declare variables by using below symbols also:

  • “=”
  • “<-”
  • “->”

check out the below image for example:

R indicators

How to Run a program in R:

to run a program in R we are taking a very simple and Globally use example is to printing “Hello World” in R.

So to printing some value we can give the values directly for integers like:



to print a string you can put your text or value inside inverted comma(“”) like:

>print(“Hello World!”)

>print(‘Hello World!’)

checkout the below image for example:


How to Declare the values in R:

To declare the values in R u can use the indicators as discussed above to declare the variable here we are going to use indicators “<-”, check out below example:

>x <- 12

>x <-50

>x <-”Hello World!”

>x <- ‘Hello World!”


Comments in R:

Comments are very important and useful part of a programming language by using comments developers make the code very simple and easy to understand. As well as they use it to find bugs easily. Its just like a marking that will not read by the program. You can make the comments in two ways:

Single line comments: use “#” at the start of your line which you want to make as a comment.

Multi-line: if there are more line you can select them and press “Ctrl+Shift+C” to make them as comment. As well as if you are using R studio then go to “code>Comment/Uncomment Lines”.

Taking input from users:

to take the input from user there are two method:

  • readline()
  • scan()

here we will discuss the readline() method.

>X <- readline();

>x <- readline(prompt = “Enter Your Name:”);

check the below image for example:


Note: This tutorial is just for introduction and to make you ready to work with R. If any topic is not cover here, that will be cover on next articles surely.

Hope you understood the basic method of working in R programming now. and now you can start to make programs and scripts with the base.

please feel free to leave your valuable comments below.

Read More:

Thank you