7 Theory

When you’re first learning R, getting on R and planning little projects and writing code is definitely the best way to learn. Reading to understand why you’re getting the output that you are or why you’re doing something the way you are doing is definitely important, but it’s always better to get hands on.

Having said that, one thing that I craved when I was learning R was to understand why people coded the way they did, or why one thing was always recommended over another in StackOverflow answers. I picked it up along the way, but there were many times where I was doing something completely unneccessary or inefficiently because I hadn’t been exposed to a discussion about why I shouldn’t be doing what I was doing. Similarly, when I eventually did come across an article outlining some of the philosophy or theory underpinning an approach, a little light switch would go and so many more things would click into place.

So this chapter is dedicated purely to some of the simple theory underpinning certain actions in R. This is an opionated piece as I hold a personal opinion on how certain things should be done in R, but that doesn’t mean that I’m right. Instead, I hope this section helps you think more deeply about what you’re trying to achieve and the best way to get there before you start your next project.