Dar 5 Lec
Dar 5 Lec
• Vector
• List
• Matrix
• Array
• Factor
• Data Frames
Data types supported by R
• Logical
• Numeric
• Integer
• Character
• Double
• Complex
• Raw
Logical
TRUE / T and FALSE / F are logical > FALSE
values. [1] FALSE
> TRUE > class(FALSE)
[1] TRUE [1] "logical"
> class(TRUE) >F
[1] "logical" [1] FALSE
>T > class(F)
[1] TRUE [1] "logical.
> class(T)
[1] "logical"
Numeric
•>2
• [1] 2
• > class (2)
• [1] "numeric"
• > 76.25
• [1] 76.25
• > class(76.25)
• [1] "numeric
Integer
Integer data type is a sub class of numeric data
type. Notice the use of “L“ as a suffix to
a numeric value in order for it to be considered
an “integer”.
> 2L
[1] 2 Functions such as is.numeric(), is.integer() can
> class(2L) be used to test the data type.
[1] "integer" > is.numeric(2)
[1] TRUE
> is.numeric(2L)
[1] TRUE
> is.integer(2)
[1] FALSE
> is.integer(2L)
[1] TRUE
Note: Integers are numeric but NOT all
numbers are integers
Character
• > 5 + 5i
• [1] 5+5i
• > class(5 + 5i)
• [1] "complex
Raw
• > charToRaw("Hi")
• [1] 48 69
• > class (charToRaw ("Hi"))
• [1] "raw"
Coercion