Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

It will take less than 1 minute to register for lifetime. Bonus Tip - We don't send OTP to your email id Make Sure to use your own email id for free books and giveaways

R – Cheat Sheet

This is a cheat sheet which aims on giving all the important concepts in a very crisp manner. Just give it a read before starting a new project in R or interviewing for a Data Science or Data Analyst or Business Analyst post.
There are various advantages and disadvantages of using R over Python, but we will not dig deep into it.
This is a cheat sheet, so if you need more help, there is this awesome website www.google.com

We will start directly with Data Types which are the building blocks of a programming language.

There are 6 object types supported in R:-
1. Vectors
2. Lists
3. Matrices
4. Arrays
5. Factors
6. Data Frames

There are 6 data types of these objects:-
1. Logical – TRUE, FALSE
2. Numeric – 56.4, 45.3
3. Integer – 1,2,3,4
4. Complex – 6+2i
5. Character – “the”, “data”, “monk”
6. Raw – Any string or anything

Let’s briefly look into each Object types:-
1. Vector

If you want to create a vector with different data types then you have to use c() to define the vector

The only thing worth mentioning here is that when you use a negative index then that index will be ignored. See the example above

2. List
Vector was the simplest object in R, next in the list is a List πŸ˜›

Let’s create a list which will include a list, a vector, and a matrix. If you don’t know much about matrix, just remember it’s a 2-dimensional object which is defined as x<-matrix(c(1,2,3,4,5,6),nrow=2) to create a matrix with 2 rows.

Give names to the elements of list. See the example below

Merge two lists

Converting a list to a vector i.e. unlisting a list


Basically all you need to know about list are:-
1. How to create a list (x <- list())
2. What all can a list include? (Anything ranging from a vector to arrays, matrix, etc.)
3. Giving name to each element of the list (use the function names())
4. Accessing elements of the list (Use [])

Matrix
A matrix is a 2-dimensional object, you need to specify the number of rows and columns, and dim names while declaring a matrix. Here dim names are the names given to the rows and columns πŸ˜›

x <- matrix(c(1,2,3,4,56,23),ncol=2,nrow=3,dimname=list(rownames,column names)

I think you must have got a gist of a matrix. You can definitely create two matrices and apply arithmetic operations like addition, subtraction, etc.
Matrix multiplication is also simple only, see the examples below

Accessing elements in a matrix

Arrays
Arrays are able to store more than 2 dimensions in itself. Vector one dimensional, list is 2-dimensional, and now this array is more than 2 dimensional. God knows where this programming language is going πŸ˜›

Give names to columns, rows, and matrix

The Data Monk services

We are well known for our interview books and have 70+ e-book across Amazon and The Data Monk e-shop page . Following are best-seller combo packs and services that we are providing as of now

  1. YouTube channelΒ covering all the interview-related important topics in SQL, Python, MS Excel, Machine Learning Algorithm, Statistics, and Direct Interview Questions
    Link – The Data Monk Youtube Channel
  2. Website – ~2000 completed solved Interview questions in SQL, Python, ML, and Case Study
    Link – The Data Monk website
  3. E-book shop – We have 70+ e-books available on our website and 3 bundles covering 2000+ solved interview questions.Β Do check it out
    Link – The Data E-shop Page
  4. Instagram Page – It covers only Most asked Questions and concepts (100+ posts). We have 100+ most asked interview topics explained in simple terms
    Link – The Data Monk Instagram page
  5. Mock Interviews/Career Guidance/Mentorship/Resume Making
    Book a slot on Top Mate

The Data Monk e-books

We know that each domain requires a different type of preparation, so we have divided our books in the same way:

1. 2200 Interview Questions to become Full Stack Analytics Professional β€“ 2200 Most Asked Interview Questions
2.Data Scientist and Machine Learning Engineer -> 23 e-books covering all the ML Algorithms Interview Questions
3. 30 Days Analytics Course – Most Asked Interview Questions from 30 crucial topics

You can check out all the other e-books on our e-shop page β€“ Do not miss it


For any information related to courses or e-books, please send an email to [email protected]

About TheDataMonkGrand Master

I am the Co-Founder of The Data Monk. I have a total of 6+ years of analytics experience 3+ years at Mu Sigma 2 years at OYO 1 year and counting at The Data Monk I am an active trader and a logically sarcastic idiot :)

Follow Me