This article lists down 10 popular machine learning algorithms and related R commands (& package information) that could be used to create respective models. The objective is to represent a quick reference page for beginners/intermediate level R programmers who working on machine learning related problems. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos.
The data.table R Package Cheat Sheet June 8th, 2017 The data.table cheat sheet helps you master the syntax of this R package, and helps you to do data manipulations. Base R Graphics Cheat Sheet David Gerard August 8, 2017. Abstract: I reproduce some of the plots from Rstudio’s ggplot2 cheat sheet using Base R graphics.
Following are the different ML algorithms included in this article:- Linear regression
- Logistic Regression
- K-Means Clustering
- K-Nearest Neighbors (KNN) Classification
- Naive Bayes Classification
- Decison Trees
- Support Vector Machine (SVM)
- Artifical Neural Network (ANN)
- Apriori
- AdaBoost

R Studio Commands Cheat Sheet
Cheat Sheet – ML Algorithms & R Commands
R Common Commands Cheat Sheet

- Linear regression: “lm” method from base package could be used for linear regression models. Following is the sample command:
- Logistic Regression: Logistic regression is a classification based model. “glm” method from base R package could be used for logistic regression. Following is the sample command:
- K-Means Clustering: “kmeans” method from base R package could be used to run k-means clustering. Following is a sample command given X is a data matrix and m is the number of clusters:
- K-Nearest Neighbors (KNN) Classification: “knn” method from “class” package could be used for K-NN modeling. One need to install and load “class” package. Following is the sample command given X_train represents a training dataset, X_test represents test data set, k represents number of nearest neighbors to be included for the modeling
- Naive Bayes Classification: “naiveBayes” method from “e1071” package could be used for Naive Bayes classification. One need to install and load “e1071” package prior to analysis. Following is the sample command:
- Decision Trees: “rpart” method from “rpart” can be used for Decision Trees. One need to install and load “rpart” package. Following is the sample command:
- Support Vector Machine (SVM): “svm” method from “e1071” package could be used for SVM. Note that the same package also provide method, naiveBayes, for Naive Bayes classification. One need to install and load “e1071” package. Following is the sample command given X is the matrix of features, labels be the vector of 0-1 class labels, and C being regularization parameter
- Artifical Neural Network (ANN): “neuralnet” method from “neuralnet” package could be used for ANN modeling. Following is sample command:
Prediction could be made using following formula:
- Apriori: “apriori” method from “arules” package could be used for Apriori analysis. One need to install and load “arules” package. Following is the sample command:
- AdaBoost: “ada” method from “rpart” package could be used as boosting function. Following is sample command:

For most of the above formulas including linear regression model, one could use following function to predict:

- First Principles Understanding based on Physics - April 13, 2021
- Precision & Recall Explained using Covid-19 Example - April 11, 2021
- Moving Average Method for Time-series forecasting - April 4, 2021

