Data Types and Operators in R
Data Types
- State the main data types used in R.
- Given an object, identify its data type.
Operators
- Explain what an operator is in the context of computer programming.
- State the arithmetic operators in R:
+
, -
, *
, ^
, /
, %%
, %/%
.
- Write and interpret expressions involving the arithmetic operators in R.
- Use the help operator
?
to pull up documentation about an operator or function.
- State the comparison operators in R:
<
, >
, <=
, >=
, !=
, ==
.
- Write and interpret expressions involving the comparison operators in R.
- State the Boolean operators in R:
&
, |
, !
.
- Write and interpret expressions involving the Boolean operators in R.
- Complete a “truth table” for two Boolean variables using one of the
&
, |
, or !
operators.
Querying and Assigning Data Types
- Explain what the
typeof
, is.*
, and as.*
functions do when passed a data object.
- 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
- Define variables in R using the assignment operator
<-
.
- Explain what ‘magic constants’ are, and why they should be avoided.
- Give reasons to use variables over magic constants.
Data Structures
Vectors
- Define a vector in the context of R.
- Create a vector object using
c
.
- Create an empty vector using the
vector
function.
Vector Access
- Access a single element of a vector using the bracket operator.
- Use the arithmetic negation operator to access all-but a single element of a vector.
- Access multiple elements of a vector using the bracket operator and a vector of indices.
- Access multiple elements of a vector using a vector of Booleans.
Vectors and Operators
- Use the arithmetic and comparison operators with vector objects.
- Explain what vector recycling is.
Naming Vector Elements
- Use
names
to name the elements of a vector.
- Access the elements of a vector with named elements.