Integers in R


Fundamentals of R
Objects in R
Integers in R

The course is part of this learning path

Integers in R

Course Description 

This module looks at more complex data structures, building on what was covered in the beginner data structures module.   

Learning Objectives 

The objectives of this module are to provide you with an understanding of: 

  • Different data types  
  • Integers  
  • How to coerce elements, and force coercion  
  • How to construct a matrix  
  • How to construct an array 
  • How to construct a list 

Intended Audience 

Aimed at all who wish to learn the R programming language. 


No prior knowledge of R is assumed. Delegates should already be familiar with basic programming concepts such as variables, scope, and functions. Experience of another scripting language such as Python or Perl would be an advantage. Understanding mathematical concepts will be beneficial.


We welcome all feedback and suggestions - please contact us at to let us know what you think. 


- [Instructor] When we think about integers in R, there are a couple of questions that come to mind. Firstly, how can we explicitly create integers? And secondly, how can we coerce an integer from, say for example, a decimal. Let's start by understanding how to explicitly create an integer. It's a simple case of adding a capital L to an element. Say, for example, three, I would like to store that as an integer in R, I would add in the capital L. And I can ask for what is the class of the subject using the class function and see integer on the screen. So that's the high level understanding. I could ask for a low level understanding of what this is by asking for the type of data that I have which is an integer. I can also ask for another feature, for example, the length that would tell me how many entries I have. In this case I only have one element, the three L which is an integer as opposed to three and L being independent. So I have a length of one. Can I coerce from say 3.6, I would like to make this into an integer. Let me ask what is the current low level data type of this. It is a double because it is having a decimal at the end. But I could, if I wanted to, coerce this to the integer type by asking for, by using the as integer function and that forces it to be three. Now even though on the screen we see three as a result, I can ask for this, using the equality symbol, I can ask, is this the same as what I had mentioned as being an integer for three? And the answer is true.

About the Author
Learning Paths

Kunal has worked with data for most of his career, ranging from diffusion markov chain processes to migrating reporting platforms.  

Kunal has helped clients with early stage engagement and formed multi week training programme curriculum. 

Kunal has a passion for statistics and data; he has delivered training relating to Hypothesis Testing, Exploring Data, Machine Learning Algorithms, and the Theory of Visualisation. 

Data Scientist at a credit management company; applied statistical analysis to distressed portfolios. 

Business Data Analyst at an investment bank; project to overhaul the legacy reporting and analytics platform. 

Statistician within the Government Statistical Service; quantitative analysis and publishing statistical findings of emerging levels of council tax data. 

Structured Credit Product Control at an investment bank; developing, maintaining, and deploying a PnL platform for the CVA Hedging trading desk.