Learning to Code in R
An introduction to practical programming in R
2022-09-11
Welcome
This book is a work in progress for an introductory textbook on programming in R.
In a nutshell, we discuss the basics of R, covering properties of data objects, such as vectors, factors, matrices, data frames, and lists. We also cover main principles for data manipulation, reshaping, tidying, etc. Likewise, we discuss fundamental notions of programming (e.g. functions, conditionals, iterations). And last but not least we describe how to make basic (and not so basic) graphics.
Yet Another R Book
Why writing another book about programming in R? Quick answer: “Why not?” The truth is that for many years I refrained myself from writing a book like the one you are reading now. I used to tell myself something along the lines of: “The world does not need another introductory book about R.” And I still somewhat agree with this. Okay, maybe the world does not need another book like this … but I do.
After using R—almost on a daily basis—for more than 16 years, and having taught STAT 133 “Concepts in Computing with Data”, for the past 6 years, I’ve accumulated a large body of notes, slides, scripts, exercises and that sort of things, that deserve a place such as this a textbook. In addition, and more important, it fits my needs when teaching courses such as STAT 133, STAT 33A, STAT 33B, STAT 243, and similar courses on programming, data analysis, data science, and related activities … with R.
As you will see, the book has an overarching theme based on financial math formulas and personal finance applications. The main reason for this decision is to provide a unifying theme under which most topics can be tidely presented, instead of offering a number of examples in a vacuum.
I hope you enjoy reading the book, learn something (hopefully a lot) about coding in R, and also a bit of financial math. Enough chit-chat. Let’s get started.