Introduction to R (2) - Objects and their schemas and properties

Objects and their schemas and properties

The entities that R operates on are technically objects. R's object types include numeric, complex, logical, character, and primitive types.

"Atomic" objects: Objects whose elements are all of the same type or pattern, such as logical vectors and string vectors.

List object: A list can be an ordered sequence of objects of any pattern. Lists are considered to be a "recursive" structure, rather than an "atomic" structure, because their elements can be listed individually in their own way.

The schema of an object is the type of the basic elements of the object.

mode(), length(): Features that all objects must have.

Change the object type:

 z<-0:9
> digits<-as.character(z) > d<-as.integer(digits) > z  [1] 0 1 2 3 4 5 6 7 8 9 > digits  [1] "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" > d  [1] 0 1 2 3 4 5 6 7 8 9

改变对象长度
e<-numeric() : Creates an empty vector structure e in numeric mode 
e[3]<-17: Will create a vector e of length 3 (the first two elements are NA, the third element is 17) to

delete the object Size: Assignment operation
alpha<-alpha[2*1:5] : At this point, an object of length 5 will be created by the elements on the even index bit value (alpha is originally an object of length 5)
length(alpha )<-3: keep only the first three values

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325965452&siteId=291194637