June 8, 2018 today is the second day of learning R feel slow, need to speed up a bit. In addition yesterday seems to write not particularly good, so today intends to study the overall editor.
Today to learn the factors, first: what is a factor? Because we know the vectors in R, and because we've been learning python for a while, we have an understanding of dictionaries, arrays, etc. So, for the factor I can be seen as a vector with a little dictionary flavor. (Personal understanding)
The definition of Baidu is this: factors are used to store categorical variables (categorical variables) and ordered variables, which cannot be used to calculate but only to classify or count. Factors represent categorical variables, and ordered factors represent ordered variables.
That is, the factor is a class and ordered variable, the equivalent of dividing the variable into discrete and continuous, the factor is the discrete vector.
For example:!!!
> a=c (' A ', ' a ', ' B ', ' O ', ' ab ', ' ab ');
[1] "a" "a" "B" "O" "AB" "AB"
> X=factor (C (' A ', ' a ', ' B ', ' O ', ' ab ', ' ab ')); x
[1] A a b o ab AB
Levels:a AB b o
Note that the output in the factor will be output in the order of the Binary tab, so it will be a first and then AB then a will not be a B
R language data structure--1 vector and factor ② factor-vector