1. Introduction Flashcards
Arithmetic operators
Parentheses: (5 / 5) + 5
Multiplication: 5 * 5
Division: 5 / 5
Addition: 5 + 5
Subtraction: 5 - 5
Variable operations
Assigning a value to a variable:
value_1 <- 50 value_2 <- 5
Assigning the result of a calculation to a variable:
total <- 5 + 5 average <- (5 + 5 + 5) / 3
Performing calculations using variable names:
value_1 + value_2
Vector operations
Create a vector of values:
vector_1 <- c(50, 5)
Create a vector using variable names
vector_1 <- c(value_1, value_2)
Built-in functions
Average of values in a vector: mean(vector_1)
Smallest value in a vector: min(vector_1)
Largest value in a vector: max(vector_1)
Total number of elements in a vector: length(vector_1)
Sum of elements in a vector: sum(vector_1)
Concepts
R uses the order of operations rules from mathematics when evaluating expressions.
There are some rules you need to follow when naming variables in R: