Data Types and Operators in R

Data Types

  1. State the main data types used in R.
  2. Given an object, identify its data type.

Operators

  1. Explain what an operator is in the context of computer programming.
  2. State the arithmetic operators in R: +, -, *, ^, /, %%, %/%.
  3. Write and interpret expressions involving the arithmetic operators in R.
  4. Use the help operator ? to pull up documentation about an operator or function.
  5. State the comparison operators in R: <, >, <=, >=, !=, ==.
  6. Write and interpret expressions involving the comparison operators in R.
  7. State the Boolean operators in R: &, |, !.
  8. Write and interpret expressions involving the Boolean operators in R.
  9. Complete a “truth table” for two Boolean variables using one of the &, |, or ! operators.

Querying and Assigning Data Types

  1. Explain what the typeof, is.*, and as.* functions do when passed a data object.
  2. State what the output would be for a given data object passed to one of the typeof, is.*, and as.* functions.

The Assignment Operator and Variables

  1. Define variables in R using the assignment operator <-.
  2. Explain what ‘magic constants’ are, and why they should be avoided.
  3. Give reasons to use variables over magic constants.

Data Structures

Vectors

  1. Define a vector in the context of R.
  2. Create a vector object using c.
  3. Create an empty vector using the vector function.

Vector Access

  1. Access a single element of a vector using the bracket operator.
  2. Use the arithmetic negation operator to access all-but a single element of a vector.
  3. Access multiple elements of a vector using the bracket operator and a vector of indices.
  4. Access multiple elements of a vector using a vector of Booleans.

Vectors and Operators

  1. Use the arithmetic and comparison operators with vector objects.
  2. Explain what vector recycling is.

Naming Vector Elements

  1. Use names to name the elements of a vector.
  2. Access the elements of a vector with named elements.