Numbers in vectors, matrices, and data frames
A number represents a point in space. You may also have heard of a number being referred to as a scalar when it is followed by a unit of measure. In other words, it is a variable with a single number. When we have more than one number, it is possible to create a line in space, which is referred to as a vector. A collection of vectors put together gives new dimensions to data, which becomes matrices or data frames. These last two are similar structures, but data frames have some more enhanced features, such as headers and indexes, that help us to work with the information held by them.
We can quickly go over scalar, vector, matrix, and data frame creation in R, which is a simple process. You can understand what is being done by reading the comments:
# Creating a scalar scalar <- 42 print(scalar) [1] 42 # Creating a vector vec <- c(1, 2, 3, 4, 5, 6, 7, 8, 9) print(vec) [1] 1 2 3 4 5 6 7 8 9 # Creating a Matrix mtrx <- matrix...