Introduction to R

A beginner-friendly introduction to the R programming language.
Author

Aravind Hebbali

Published

November 13, 2026

Preface

Introduction to R book cover

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Structure of the book

Chapter Introduction to R gives a quick overview of R and its development tools. Chapter Install R & RStudio guides you through installing R and RStudio. Chapter Variables in R introduces variables and assignment. Chapter Data Types in R introduces the types of values used in R. Chapter Vectors in R covers vectors, coercion, operations and indexing. Chapter Dataframes in R covers creating and selecting rows and columns in data frames. Chapter Install & Update R Packages covers installing, loading and updating packages. Chapter RStudio Projects & Data Import covers portable paths and reading CSV and Excel files. Chapter Your First Visualization introduces base R and ggplot2 graphics. Chapter Your First Data Wrangling introduces dplyr verbs and the native pipe. Chapter Factors in R covers categorical data, levels and labels. Chapter Lists in R covers storing and extracting elements of different types. Chapter Getting Help in R shows where and how to ask for help and find documentation. About the Author follows the chapters, and Package management collects reference material in an appendix.

Software information

The R session information below shows the setup used to compile this book:

sessionInfo()
R version 4.5.3 (2026-03-11)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.5 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
 [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
 [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
[10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

time zone: UTC
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

loaded via a namespace (and not attached):
 [1] htmlwidgets_1.6.4 compiler_4.5.3    fastmap_1.2.0     cli_3.6.6        
 [5] htmltools_0.5.9   tools_4.5.3       otel_0.3.0        yaml_2.3.12      
 [9] rmarkdown_2.32    knitr_1.52        jsonlite_2.0.0    xfun_0.62        
[13] digest_0.6.39     rlang_1.3.0       renv_1.2.4        evaluate_1.0.5   

We do not add prompts (> and +) to R source code in this book. We comment out text output with two hashes ## by default, as in the R session information above. This lets you copy and run the code, since R ignores the commented text output. Package names are in bold text (e.g., rmarkdown), and function names are followed by parentheses (e.g., mean()). The double-colon operator :: means accessing an object from a package.