R – Cheat Sheet
This is a cheat sheet which aims
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
Give names to the elements of
Merge two lists
Converting a list to a vector i.e. unlisting a list
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
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
- 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 - Website βΒ ~2000 completed solved Interview questions in SQL, Python, ML, and Case Study
Link βΒ The Data Monk website - 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 - 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 - 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]