# R: An Introduction

R is a programming language focused on statistics, data visualization, and data analysis. It is open source, which means there is a rich trove of libraries and add-ons constantly being developed by the open source community.

• Windows
• Linux Binaries
• RStudio – Not required, but anyone looking for a better developed environment may want to check it out. I will be using just the base install of R for the following lessons though

## Starting R

When R first starts up, this is what you will see. I am not going to focus too much on a grand tour, as most of the menus in R are pretty self explanatory. Instead, let’s jump right into the coding. Move your cursor to where my big red arrow is:

## Basic Syntax

There is an unwritten rule that states the first line of code you need to learn in any language is Hello World. Well, I am not going to do that. R is a stats program. Why don’t we start with some numbers instead.

As you can see, R uses your standard arithmetic operations (+,-,*,/,^)

## Variables

Assigning variables in R is easy. “<-” is the designated syntax used to assign a variable. One great thing about R is that you do not need to declare variables in advance. R assigns the data type based on the input you give the variable.

Assigning Strings

## Data Types

The main data types in R are:

• Numeric: 1, 2.33, etc
• Integer: 2L
• Logical: TRUE, FALSE
• Character: string
• Complex: 2+3i (remember those from Trig class)

## Vectors

Vectors allow you group multiple elements under one name. Use the syntax <-c() when creating a vector

## Lists

Lists allow you to group unlike items – even vectors and strings:

## 3 thoughts on “R: An Introduction”

1. Detailed and good explanation on the topic. I am keen to learn ‘R’. Please post more articles on this subject. Thanks for sharing

1. I will make sure to work on that. I just posted a new one today. I promise to post more.

2. Anonymous

Ben, thank you so much for your wonderful work. This is the best site for free learning, based on my research. I made a comparative analysis.