R Vectors
R Vectors In R, the most basic type of data is called a vector. A vector is simply a collection of elements, and even a single number is treated as a vector with one element. Matrices and arrays are also just special kinds of vectors with extra structure, like rows and columns. Vectors can store different kinds of data, but all the elements in a single vector must be of the same type, also called mode. The main types are integer for whole numbers, numeric for decimal numbers, character for text, logical for TRUE or FALSE, and complex for complex numbers. To combine a list of items into a vector, we use the c() function, separating the items with commas. One important point is that R indexing starts at 1, not 0, so the first element of any vector is accessed with [1]. We can check the type of a vector using the mode() function, and the length using the length() function. Vectors are very important in R because almost everything ...