5 basic types of objects in a R
Character (character) integer (integer) complex (complex) logical (Logical:true/false) value (numeric:real numbers)
To view the command for an object type: Class (X)
There are several data structures in the two R languages:
The elements within vector vectors () groups must be of the same type, otherwise they will be cast.
(1) Three ways to create vectors:
<span style= "FONT-SIZE:18PX;" >x <-vector ("numeric", length = ten)
x <-1:4
x <-C ("a", 12,true) </span>
(2) Several functions of the cast:
As.numeric (x)/As.character (x)/as.logical (x) matrices matrix () a column of filled elements
Merge by row: Rbind () Merge by column: Cbind () array () can have more than one dimension list () can contain different types of element factors factor ()
(1) Categorical data/order vs. disorder
(2) Integer vector + label (label) (better than integer vector)
Male/female vs. 1/2
Commonly used in LM (), GLM ()
(3) Levels set baseline level
Table () View factor Information Unclass () remove factor attribute
Date
x <-sys.date () get the system current date
Julian (x) x distance from 1970-01-01 days posixct/posixlt
Posixct: integer, often used to deposit data box as. Posixct ()
Posixlt: List, also contains information such as week, month, day, etc. As. Posixlt ()
Strptime (x, format = "...") converts a generic format to a time format