col_spec | R Documentation |
col_types
in readr::read_csv()
Returns the compact string representation for the col_types
argument in
readr::read_csv()
and related functions of the supplied data
. The intended
use is to record the types after an initial load (with any further processing), so it
can be used for future reads of the same data.
col_spec(data)
data |
A data frame. |
The column types will be one of:
c = character
i = integer
d = double
l = logical
f = factor
D = date
T = date time
t = time
These types are read directly from data
- there is no guessing or coercion.
The first four are identified using typeof()
. The remainder overwrite the type if
one of the following is true for the column: is.factor()
, lubridate::is.Date()
,
lubridate::is.POSIXt()
, or "hms" %in% class(.)
.
This function is unnecessary because you can use the spec()
directly as col_types
or
extract the string using as.character(spec(x))
. Also this function will not capture the
col_number()
specification which reads values such as "£10.50" or "1,234" correctly.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.