# Basic Introduction To R Programming Language

May 16, 2020 · 4 min read

In this article we will cover the intro basics to R Programming Language. This article is meant for people willing to start programming in R, beginners in R who are willing to expand their already gained knowledge in R, or people willing to start their Data Science journey using R programming language. If you are familiar with other programming languages, getting to understand R programming language will be as easy as drinking water.

# What is R?

According to Wikipedia: R is a programming language and free software environment for statistical computing and graphics supported by the R Foundation for Statistical Computing. The R language is widely used among statisticians and data miners for developing statistical software and data analysis.

R language provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, …) and graphical techniques, and is highly extensible. READ MORE>>

# How to Install and Getting Started With R

Once you have R and Rstudio installed, let’s proceed to the business of the Day.

# Intro To R Basics

## Hello, World!

`print` prints its argument and returns it invisibly

In order to print `Hello, World!` in R, you need to pass the string `"Hello, World!"` in the `print()` function. the strings can be in double quotes `""` or single quotes `''`.

The output will be as follows:

`[1] "Hello, World!"`

## Rules for Naming Variables in R

unlike other languages, Underscore(`_`) at the beginning of the variable name are NOT allowed in R

• Keywords CANNOT be used to name variables
• Special Character like `#`, or `&` and whitespace eg tab or space CANNOT be used in variable names
• Variable names are Case Sensitive, therefore, `my_name` is different from `my_Name`.

Below are examples of correct variable names and assignment in R:

Their output are as follows:

`[1] 17[1] "Victor"[1] 17347.38`

# R Arithmetic Operators

Let us use R arithmetic operators to calculate my age. We will use the already gained knowledge of variables and arithmetic operations we’ve discussed above.

`[1] 19`

As you can see `age` is a variable that stores the computations done when subtracting `year_of_birth` from `current_year`.

`[1] 19`

# Basic Data Types in R

Data type is the classification/categorization of data item. Everything in python is an object therefore, data types are classes and variables are the instance (object) of the data type. Use `class(variable_name)` in order to understand to which data type a variable belongs.

To get you started with R Basic Data types, note the following:

• Decimal values are called numerics
• Natural Numbers are called Integers, Integers are also numerics
• Boolean values, eg( `FALSE` or `TRUE`) are called logical. R is case sensitive, logicals must be in UPPERCASE
• String values/text values are called characters
`[1] "numeric"[1] "numeric"[1] "character"[1] "logical"`

# More Resources

• Introduction to R Online Course | DataCamp: link

And that marks the end of this article, keep an eye for more R articles as I cover more of R programming language to get you started in Data Science with R. Have any question? Ask Me on the comments.

Written by

Written by