...

/

Basics of R

Basics of R

Get introduced to the R programming language.

Overview

The purpose of this first chapter is to introduce the essential workings of R and get us up to speed with the basics of the language. Some of this material may be familiar to us if we’ve used R before, but the goal is to get anyone reading the course up to a basic level of familiarity with R. In this chapter, we’ll learn many of the primary and essential functions of R, such as the following:

  • We’ll learn to create objects.
  • We’ll cover writing articulate code in R.
  • We’ll explore how to use functions.
  • We’ll learn about generating artificial data.
  • We’ll discuss entering data in a format that can be read and analyzed by R.

This chapter isn’t intended to be a complete introduction to all the essential workings of R.

Before we get started

Before we begin, there are a couple of valuable things to know about R and how it works.

Always start with raw data

We import our raw file from Excel or whatever program we use for data entry, but we do whatever data processing is necessary (removing outliers, calculating new variables from old ones, and so on) within an R script. This way, we have a record that others can follow, leading them from the raw data to the final product. This also increases ...