3 Getting Started with R, RStudio and Posit.Cloud

This chapter introduces R, a leading language for statistical computing, and RStudio, the integrated development environment (IDE) that makes working with R more accessible and efficient. We cover the essentials: writing and running R code, working with variables and data structures, using functions and packages, and programming with loops, conditionals, and scripts. By the end of the chapter, you will have a working foundation in R that prepares you for the data analysis tasks in the chapters ahead.

We adopt a coding approach to BI in this textbook because writing code reveals the mechanics behind analytical processes. This understanding transfers across tools — an analyst who knows how a regression works in R can evaluate the output of any platform. We also introduce AI coding assistants, which are transforming how analysts write and learn code, and explain how to use them effectively alongside the R skills developed in this chapter.

Chapter Goals

Upon concluding this chapter, readers will be able to:

  1. Set up and navigate the RStudio environment, either through Posit.Cloud or a local installation, and write and execute R scripts.
  2. Apply R’s core data structures — vectors, data frames, lists, and factors — to organize and manipulate data for analysis.
  3. Use functions, packages, loops, and conditional statements to automate data manipulation and perform statistical calculations.
  4. Explain how AI coding assistants such as Claude Code can accelerate R programming, and why understanding R fundamentals remains essential when using AI tools.
  5. Write clear, well-documented R code using comments, scripts, and reusable functions.