Data Mode: The Mode function displays the pattern of any object. of common
singleThe object pattern is a logical (Logical), numeric (Numeric), character (Character) type. The commonly used data pattern is the list.
- Logical: True and FALSE are uppercase letters, true->1,false->0 when converted to numeric.
- Character type: Single or double quotation marks can be used when entering character type, and double quotation mark when output
- List: Allows data in multiple modes, and a data frame is a list. matrices, vectors, and so on require all data to be in the same pattern.
conversion between data schemas :
- as.character-> conversion to character type
- as.numeric-> character-type conversion numerical type
- as.logical-> character-type conversion logic
Data type : Class function Displays the classes of the object. Common vector (vertor), data frame (frame), Matrix, Factor (Factor).
- Factor: Special processing of factors in statistical modeling and cartographic functions. But when the mode function is checked, it is returned as a numeric type .
- Date and time: Although can be stored in character type, but inconvenient to special treatment.
Lists allow multiple patterns of data, and you can use the Sapply function when you want to get the patterns and classes for each component:
> mylist = List (a = C (n/a), B = C (' A ', ' B ', ' C '), C = C (true,false), d = factor (' house '));
> sapply (Mylist,mode)
A B c D
"Numeric" "character" "Logical" "numeric"
> sapply (Mylist,class)
A B c D
"Numeric" "character" "logical" "factor"
R-mode (mode) and classes (class)