Vectors are the most basic type of data in R, and there are no separate scalars in R (for example, 1 is C (1) in nature) Note that the subscript for R is a negative number starting with 1 that does not select these subscripts, for example:
> A <-C (2,5,8)
> A[-2]
[1] 2 8
The loop-up vector has a more interesting property, when two vectors are operated, if the length is not equal, the shorter one will copy itself until it is as long as it is long.
> A <-C (3,4)
> B <-C (1,2,5,6)
> A+b
[1] 4 6 8
Create a new matrix
> A <-matrix (c (1,2,3,4), nrow = 2)
> A
[, 1] [, 2]
[1,] 1 3
[2,] 2 4
You can see that the vector element becomes a matrix element in columns, from the first column to the second column, if we want to enter the element by row, then we need to add Byrow = True parameter in R we add two percent sign to multiply next to multiplication:
> a%*%a
[, 1] [, 2]
[1,] 7 10
[2,]
In general we need to analyze the data, each row represents a sample, each column represents a variable
Introduction to R language