F Learning Objectives

F.1 Values and Vectors

  • Name and describe R’s atomic data types and create objects of those types.
  • Explain what ‘scalar’ values actually are in R.
  • Identify correct and incorrect variable names in R.
  • Create vectors in R and index them to select single values, ranges of values, and selected values.
  • Explain the difference between NA and NULL and correctly use tests for each.

F.2 Indexing

  • Explain the difference between a list and a vector.
  • Explain the difference between indexing with [ and with [[.
  • Use [ and [[ correctly to extract elements and sub-structures from data structures in R.
  • Create a named list in R.
  • Access elements by name using both [ and $ notation.
  • Correctly identify cases in which back-quoting is necessary when accessing elements via $.
  • Create and index matrices in R.

F.3 Control Flow

  • Create for loops and if/else statements in R.
  • Explain why vectors cannot be used directly in conditional expressions and correctly use all and any to combine their values.
  • Define functions taking a fixed number of named arguments and/or a variable number of arguments.
  • Explain what vectorization is and create vectorized equivalents of unnested loops containing simple conditional tests.

F.4 The Tidyverse

  • Install and load packages in R.
  • Read CSV data with R.
  • Explain what a tibble is and how tibbles related to data frames and matrices.
  • Describe how read_csv infers data types for columns in tabular datasets.
  • Name and use three functions for inspects tibbles.
  • Select subsets of tabular data using column names, scalar indices, ranges, and logical expressions.
  • Explain the difference between indexing with [ and with [[.
  • Name and use four functions for calculating aggregate statistics on tabular data.
  • Explain how these functions treat NA by default, and how to change that behavior.
  • Name, describe, and use a tidyverse function for choosing rows by value from tabular data.
  • Name, describe, and use a tidyverse function for reordering rows of tabular data.
  • Name, describe, and use a tidyverse function for selecting columns of tabular data.
  • Name, describe, and use a tidyverse function for calculating new columns from existing ones.
  • Name, describe, and use a tidyverse function for grouping rows of tabular data.
  • Name, describe, and use a tidyverse function for aggregating grouped or ungrouped rows of tabular data.

F.5 Cleaning Up Data

  • Describe and use the read_csv function.
  • Describe and use the str_replace function.
  • Describe and use the is.numeric and as.numeric functions.
  • Describe and use the map function and its kin.
  • Describe and use pre-allocation to capture the results of loops.

F.6 Testing and Error Handling

  • Name and describe the three levels of error handling in R.
  • Handle an otherwise-fatal error in a function call in R.
  • Create unit tests in R.
  • Create unit tests for an R package.

F.7 Non-Standard Evaluation

  • Trace the order of evaluation in function calls.
  • Explain what environments and expressions are and how they relate to one another.
  • Justify the author’s use of ASCII art in the second decade of the 21st Century.

F.8 Object-Oriented Programming

  • Correctly identify the most commonly used object-oriented programming system in R.
  • Explain what attributes R and correctly set and query objects’ attributes, class, and dimensions.
  • Explain how to define a new method for a class.
  • Describe and implement the three functions that should be written for any user-defined class.

F.9 Intellectual Debt

  • Explain what the formula operator ~ was created for and what other uses it has.
  • Describe and use ., .x, .y,..1,..2`, and other convenience parameters.
  • Define copy-on-modify and explain its use in R.

F.10 Projects

  • Describe the three things an R package can contain.
  • Explain how R code in a package is distributed and one implication of this.
  • Explain the purpose of the DESCRIPTION, NAMESPACE and .Rbuildignore files in an R project.
  • Explain what should be put in the R, data, man, and tests directories of an R project.
  • Describe and use specially-formatted comments with roxygen2 to document a package.
  • Use @export and @import directives correctly in roxygen2 documentation.
  • Add a dataset to an R package.
  • Use functions from external libraries inside a package in a hygienic way.
  • Rewrite references to bare column names to satisfy R’s packaging checks.
  • Correctly document the package as a whole and the datasets it contains.

F.11 Web Applications with Shiny

  • Describe the three essential parts of a Shiny application.
  • Explain how element names are used to connect interface elements to server actions.
  • Describe the structure of a simple Shiny application and how to run it.
  • Explain what reactive variables are and how they differ from normal variables.
  • Use functions to create and style HTML elements.
  • Explain how to avoid circular updates in interfaces.

F.12 Reticulate

  • Use reticulate to share data between R and Python.
  • Use reticulate to call Python functions from R code and vice versa.
  • Run Python scripts directly from R programs.