Table of Contents

    Data Types in R Programming Language: Overview and Examples

    Data Types in R Programming Language: Overview and Examples

    In contrast to other programming languages like C and Java in R, the variables are not declared as some data type. The variables are assigned with R-Objects and the data type of the R-object becomes the data type of the variable. There are many types of R-objects. The frequently used ones are ?

    • Vectors
    • Lists
    • Matrices
    • Arrays
    • Factors
    • Data Frames

    The simplest of these objects is the vector object and there are six data types of these atomic vectors, also termed as six classes of vectors. The other R-Objects are built upon the atomic vectors.

    Data Type Example Verify
    Logical TRUE, FALSE
    var

    it produces the following result ?

    [1] "logical"
    Numeric 12.3, 5, 999
    var

    it produces the following result ?

    [1] "numeric"
    Integer 2L, 34L, 0L
    var

    it produces the following result ?

    [1] "integer"
    Complex 3 + 2i
    var

    it produces the following result ?

    [1] "complex"
    Character 'a' , '"good", "TRUE", '23.4'
    var

    it produces the following result ?

    [1] "character"
    Raw "Hello" is stored as 48 65 6c 6c 6f
    var

    it produces the following result ?

    [1] "raw"
    Date "2019-08-07"
    date

    it produces the following result ?

    [1] "Date"
    date

    it produces the following result ?

    [1] "POSIXct" "POSIXt"