• Unit 2: Basic Object Types and Operations in R

    Data surround us in every shape and form in our daily life: not just as numbers we may see in a weather report but also as sounds, text, and images. By representing data in a standard way in R, we can apply various R functions for data analysis. This unit introduces commonly used data types and explains how the data can be organized as objects in our coding environment. We also discuss how to subset and join several such objects and change the object type.

    Completing this unit should take you approximately 3 hours.

    • 2.1: Data Types

      R's variety of data types most likely covers all possible statistical analysis needs. This section introduces the common types and provides more details on strings and factors.

    • 2.2: Vectors

      Vector is the simplest data structure in R and a building block for more complex objects. You should learn how to create and subset or select elements in a vector.

    • 2.3: Arrays and Matrices

      Matrices have two dimensions, and arrays have three or more dimensions. For example, a digital color image of 100×100 pixels can be represented by an array with dimensions 100×100×3, where 3 represents the red, green, and blue (RGB) color representation. Data in matrices or arrays are all of one type or missing (NA), which makes these objects efficient to work with.

    • 2.4: Lists and Data Frames

      List objects in R allow us to combine data of different types and sizes. The list is the most flexible R object, however, the user typically pays for this flexibility with reduced performance (speed of computations) or excessive verbose coding needed to refer to a specific element in a list. This section introduces the base-R list implementations (list and data.frame) and contributed modifications (tibble and data.table) to the data.table format. These modifications address the issues of computing inefficiency and code repetitiveness. The goal is to get familiar with each format (data.frame, tibble, and data.table).

    • Unit 2 Assessment

      • Receive a grade