Key Concepts

Review core concepts you need to learn to master this subject

R vectors

my_string_vector <- c("this", "is", "an", "example", "vector") my_string_vector[3] # returns "an" my_boolean_vector <- c(TRUE, FALSE, FALSE) my_numerical_vector <- c(0.4, 0.9, 1, 0.45, 1.2, 0.33) # R will force the same type even if you input different types to c() my_vector <- c("word", 45, 12, FALSE) # result: a vector of strings "word" "45" "12" "FALSE"

A vector is a data structure that can hold multiple objects of the same data type. For example, c(45, 25, 89, 10) creates a numerical vector. To access elements, use the [ ] brackets with indexing starting from 1.