cols: Create column specification

Description Usage Arguments Details See Also Examples

View source: R/col_types.R

Description

cols() includes all columns in the input data, guessing the column types as the default. cols_only() includes only the columns you explicitly specify, skipping the rest.

Usage

1
2
3
cols(..., .default = col_guess())

cols_only(...)

Arguments

...

Either column objects created by col_*(), or their abbreviated character names (as described in the col_types argument of read_delim()). If you're only overriding a few columns, it's best to refer to columns by name. If not named, the column types must match the column names exactly.

.default

Any named columns not explicitly overridden in ... will be read with this column type.

Details

The available specifications are: (with string abbreviations in brackets)

See Also

Other parsers: col_skip, cols_condense, parse_datetime, parse_factor, parse_guess, parse_logical, parse_number, parse_vector

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
cols(a = col_integer())
cols_only(a = col_integer())

# You can also use the standard abbreviations
cols(a = "i")
cols(a = "i", b = "d", c = "_")

# You can also use multiple sets of column definitions by combining
# them like so:

t1 <- cols(
  column_one = col_integer(),
  column_two = col_number())

t2 <- cols(
 column_three = col_character())

t3 <- t1
t3$cols <- c(t1$cols, t2$cols)
t3

hadley/readr documentation built on Sept. 12, 2019, 10:57 p.m.