R Essentials: A Beginner’s Guide to Data Analysis

Author

Tengku Muhammad Hanis Bin Tengku Mokhtar, PhD

Published

Nov 24, 2025

Welcome

WarningThis book is currently in its drafting stages and has not yet been published. While all the chapters are complete, most of them are still undergoing further revision and refinement.

This book is intended for anyone interested in using R for applied statistical analysis and machine learning. I first encountered R (specifically RStudio) during my master’s studies, and it wasn’t an easy journey—especially as someone from a non-coding background. Initially, I was introduced to software like SPSS and STATA, and eventually R during my master’s studies. R felt unfamiliar and complex by comparison to the previous software. However, those who could use R proficiently seemed impressive to me, which motivated me to keep going. Surprisingly, the learning process became much easier as I keep using R.

Looking back, I wish I had known certain things earlier in my journey of learning R. This book is my attempt to provide those insights, covering the key concepts and tips I wish I had had when I started. I hope it sparks interest in R for others and helps them fully utilize its capabilities.

NoteAs Prophet Muhammad (Peace Been Upon Him) said:

“When a man dies, his deeds come to an end except for three things: Sadaqah Jariyah (ceaseless charity); a knowledge which is beneficial, or a virtuous descendant who prays for him (for the deceased).”

I hope my effort in writing this book will be considered as a beneficial knowledge to others.

Finally, I would like to express my deepest love and gratitude to my late wife, Nurul Asmaq. You will always remain in my heart and in my thoughts — Al‑Fatihah.

To my son, Hanif, who gives me purpose, and to my parents, Tengku Mokhtar and Nor Malaysia: thank you. Writing this book meant taking time away from them, and even if my obsession with R and data analysis is hard to understand, their support has meant the world to me.

Tengku Muhammad Hanis Bin Tengku Mokhtar, PhD