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, mode
Other functions to check the object type:
is.integer, is.double, is.logical, is.character
The complex numbers consist of a real part and an imaginary part, which is identified by lower-case
i
The
raw
vector stores raw bytes of data. Eachraw
byte 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.vector
tests whether an object is an atomic vector. It returnsTRUE
if 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
length
returns the length of an atomic vector