# Column data types

    library(tibble)

This vignette shows an overview of known data types and their abbreviations, and their origin. For example, `<int>` in the header of a column indicates an integer column, and `<chr>` denotes a character column.

Class | Data type | Example | Column header
--- | --- | --- | ---
Atomic | logical | `TRUE` | lgl
| integer | `1L` | int
| double | `1.5` | dbl
| character | `"A"` | chr
| complex | `0+1i` | cpl
| raw | `as.raw(1)` | raw
| list | `list(1)` | list
| named list | `list(a = 1)` | named list
Built-in objects | factor | `factor("A")` | fct
| ordered | `ordered("a")` | ord
| Date | `Sys.Date()` | date
| POSIXt | `Sys.time()` | dttm
| difftime | `vctrs::new_duration(1)` | drtn
Objects from other packages | hms | `hms::hms(1)` | time
| integer64 | `bit64::as.integer64(1e+10)` | int64
| blob | `blob::blob(raw(1))` | blob
Data frames | data.frame | `data.frame(a = 1)` | df[,1]
| tbl_df | `tibble(a = 1)` | tibble
Unchanged | AsIs | `I(1L)` | I
vctrs types | unspecified | `vctrs::unspecified(1L)` | ???
| vctrs_list_of | `vctrs::list_of(c(1L))` | list
| vctrs_vctr | `vctrs::new_vctr(1L)` | vctrs_vc
| vctrs_unspecified | `vctrs::unspecified(1)` | ???
| vctrs_partial_factor | `vctrs::partial_factor(letters)` | prtl_fctr
| vctrs_partial_frame | `vctrs::partial_frame(a = 1)` | prtl
Language objects | function | `function() NULL` | fn
| symbol | `quote(a)` | sym
| expression | `parse(text = "a <- 1\nb<- 2")` | expression
| quosures | `rlang::quos(a = 1)` | quos

The following overview contains example values for each type:

    #> Rows: 1
    #> Columns: 24
    #> Warning: Subsetting quosures with `[[` is deprecated as of rlang 0.4.0
    #> Please use `quo_get_expr()` instead.
    #> $ [1mlogical          [22m [3m[90m<lgl>[39m[23m TRUE
    #> $ [1minteger          [22m [3m[90m<int>[39m[23m 1
    #> $ [1mdouble           [22m [3m[90m<dbl>[39m[23m 1.5
    #> $ [1mcharacter        [22m [3m[90m<chr>[39m[23m "A"
    #> $ [1mcomplex          [22m [3m[90m<cpl>[39m[23m 0+1i
    #> $ [1mraw              [22m [3m[90m<raw>[39m[23m 01
    #> $ [1mlist             [22m [3m[90m<list>[39m[23m [1]
    #> $ [1m`named list`     [22m [3m[90m<named list>[39m[23m [1]
    #> $ [1mfactor           [22m [3m[90m<fct>[39m[23m A
    #> $ [1mordered          [22m [3m[90m<ord>[39m[23m a
    #> $ [1mDate             [22m [3m[90m<date>[39m[23m 2020-04-19
    #> $ [1mPOSIXt           [22m [3m[90m<dttm>[39m[23m 2020-04-19 21:10:24
    #> $ [1mdifftime         [22m [3m[90m<drtn>[39m[23m 1 secs
    #> $ [1mhms              [22m [3m[90m<time>[39m[23m 00:00:01
    #> $ [1minteger64        [22m [3m[90m<int64>[39m[23m 10000000000
    #> $ [1mblob             [22m [3m[90m<blob>[39m[23m blob[1 B]
    #> $ [1mdata.frame       [22m [3m[90m<df[,1]>[39m[23m <data.frame[1 x 1]>
    #> $ [1mtbl_df           [22m [3m[90m<tibble>[39m[23m <tbl_df[1 x 1]>
    #> $ [1mAsIs             [22m [3m[90m<I<int>>[39m[23m 1
    #> $ [1munspecified      [22m [3m[90m<???>[39m[23m NA
    #> $ [1mvctrs_list_of    [22m [3m[90m<list<int>>[39m[23m 1
    #> $ [1mvctrs_vctr       [22m [3m[90m<vctrs_vc>[39m[23m 1
    #> $ [1mvctrs_unspecified[22m [3m[90m<???>[39m[23m NA
    #> $ [1mquosures         [22m [3m[90m<quos>[39m[23m [~1]

## Implementation

The column header is obtained by calling `pillar::type_sum()` on the column. This is an S3 method that can be overridden, but most of the time it is more useful to override `vctrs::vec_ptype_abbr()`:

    pillar:::type_sum.default
    #> function(x) {
    #>   if (is.object(x)) return(vctrs::vec_ptype_abbr(x))
    #>   # r-lib/vctrs#323:
    #>   if (typeof(x) == "complex") return("cpl")
    #>   if (vec_is(x)) return(vctrs::vec_ptype_abbr(x))
    #>
    #>   switch(typeof(x),
    #>     builtin = ,
    #>     special = ,
    #>     closure = "fn",
    #>     environment = "env",
    #>     symbol =
    #>       if (is_missing(x)) {
    #>         "missing"
    #>       } else {
    #>         "sym"
    #>       },
    #>
    #>     typeof(x)
    #>   )
    #> }
    #> <bytecode: 0x564afb430f78>
    #> <environment: namespace:pillar>