Comments and basic arithmetic operations in R programming

Sharing is Caring

This post is about performing arithmetic operations in R programming language and putting required comments in between of code.

In R we use #(hash) sign to write a single line comment and R does not support multiline comments.

Now we’ll see how to perform basic arithmetic operations in R. It is quite simple like using the calculator as no code is required to add, subtract or multiply.
See the example given below and try the code in R GUI software.

#Add Operation

#Subtract Operation



# Exponentiation

# Modulo

And see the output in R GUI

Arithmetic Operations in R

and you can see that comments are written in code using # sign.

Print Hello World in R

The first program of every programming language is printing “Hello World” on the screen so here we’ll see how to write our first program in R.
Here we take a variable sayHello and use <- to assign the value to the variable and to print this variable on the console, use the print command as shown in below code.

#Set value in a variable 
sayHello <- "Hello World in R Programming!"
#Put this command to print

And output in R console – It is printing “Hello World in R Programming”

Hello World in R

So this post gives a basic idea about R programming, Now in next post, we’ll learn about variables and data-types used in R language.

Related Posts

An Oracle ACE, Blogger, Reviewer, Technical Lead working on Oracle ADF

Leave a Reply

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