Section 15 Atomic Class: Summary
15.1 R Atomic Class
| Class | Concept | Example |
|---|---|---|
integer |
Integer | 1L, -5L |
double |
Double | 1.0, 3.14, 5.3E-12, 22/7 |
character |
Character | 'a', 'A', 'Sam', 'David', '1', 'one' |
logical |
Logical | a <- 3 > 4, T/F, TRUE/FALSE |
complex |
Complex | 3 + 4i |
raw |
Raw | raw(5) |
15.2 Points to note
Function to identify the object type:
class, typeof, modeOther functions to check the object type:
is.integer, is.double, is.logical, is.characterThe complex numbers consist of a real part and an imaginary part, which is identified by lower-case
iThe
rawvector stores raw bytes of data. Eachrawbyte is represented by a two-digit hexadecimal value. They are primarily used for storing the contents of imported binary files, and as such are reasonably rare.Function
is.vectortests whether an object is an atomic vector. It returnsTRUEif the object is an atomic vector and FALSE otherwise.You can make an atomic vector with just one value. R saves single value as an atomic vector of length 1
lengthreturns the length of an atomic vector