Skip to content

Commit

Permalink
Add documentation around long names for column types
Browse files Browse the repository at this point in the history
  • Loading branch information
jimhester committed Aug 5, 2021
1 parent 022ebe5 commit a08db02
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 29 deletions.
5 changes: 3 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# vroom (development version)

* `vroom(col_types=)` now accepts column type names like those accepted by utils::read.table. e.g.
vroom::vroom(col_types = list(a = "integer", b = "double", c = "skip"))

* `vroom()` now respects the `quote` parameter properly in the first two lines of the file (https://github.com/tidyverse/readr/issues/1262)

* `vroom_write()` now always correctly writes its output including column names in UTF-8 (https://github.com/tidyverse/readr/issues/1242)

* `vroom_write()` now creates an empty file when given a input without any columns (https://github.com/tidyverse/readr/issues/1234)

* `vroom(col_types=)` now accepts column type names like those accepted by utils::read.table.

# vroom 1.5.3

* `vroom(col_types=)` now truncates the column types if the user passes too many types. (#355)
Expand Down
34 changes: 21 additions & 13 deletions R/col_types.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
#' as the default. `cols_only()` includes only the columns you explicitly
#' specify, skipping the rest.
#'
#' The available specifications are: (with string abbreviations in brackets)
#' The available specifications are: (long names in quotes and string abbreviations in brackets)
#'
#' * `col_logical()` \[l\], containing only `T`, `F`, `TRUE` or `FALSE`.
#' * `col_integer()` \[i\], integers.
#' * `col_big_integer()` \[I\], Big Integers (64bit), requires the `bit64` package.
#' * `col_double()` \[d\], doubles.
#' * `col_character()` \[c\], everything else.
#' * `col_factor(levels, ordered)` \[f\], a fixed set of values.
#' * `col_date(format = "")` \[D\]: with the locale's `date_format`.
#' * `col_time(format = "")` \[t\]: with the locale's `time_format`.
#' * `col_datetime(format = "")` \[T\]: ISO8601 date times
#' * `col_number()` \[n\], numbers containing the `grouping_mark`
#' * `col_skip()` \[_, -\], don't import this column.
#' * `col_guess()` \[?\], parse using the "best" type based on the input.
#' | function | long name | short name | description |
#' | ---------- | ----------- | ---------- | ------------- |
#' | `col_logical()` | "logical" | "l" | Logical values containing only `T`, `F`, `TRUE` or `FALSE`. |
#' | `col_integer()` | "integer" | "i" | Integer numbers. |
#' | `col_big_integer()` | "big_integer" | "I" | Big Integers (64bit), requires the `bit64` package. |
#' | `col_double()` | "double", "numeric" | "d" | 64-bit double floating point numbers.
#' | `col_character()` | "character" | "c" | Character string data. |
#' | `col_factor(levels, ordered)` | "factor" | "f" | A fixed set of values. |
#' | `col_date(format = "")` | "date" | "D" | Calendar dates formatted with the locale's `date_format`. |
#' | `col_time(format = "")` | "time" | "t" | Times formatted with the locale's `time_format`. |
#' | `col_datetime(format = "")` | "datetime", "POSIXct" | "T" | ISO8601 date times. |
#' | `col_number()` | "number" | "n" | Human readable numbers containing the `grouping_mark` |
#' | `col_skip()` | "skip", "NULL" | "_", "-" | Skip and don't import this column. |
#' | `col_guess()` | "guess", "NA" | "?" | Parse using the "best" guessed type based on the input. |
#'
#' @param ... Either column objects created by `col_*()`, or their abbreviated
#' character names (as described in the `col_types` argument of
Expand All @@ -31,6 +33,7 @@
#' used in the call to `vroom()` it takes precedence over the one specified in
#' `col_types`.
#' @export
#' @aliases col_types
#' @examples
#' cols(a = col_integer())
#' cols_only(a = col_integer())
Expand All @@ -39,6 +42,9 @@
#' cols(a = "i")
#' cols(a = "i", b = "d", c = "_")
#'
#' # Or long names (like utils::read.csv)
#' cols(a = "integer", b = "double", c = "skip")
#'
#' # You can also use multiple sets of column definitions by combining
#' # them like so:
#'
Expand Down Expand Up @@ -306,6 +312,7 @@ spec <- function(x) {
col_concise <- function(x) {
switch(x,
"_" = ,
"skip" =,
"NULL" =,
"-" = col_skip(),
"NA" = ,
Expand All @@ -315,6 +322,7 @@ col_concise <- function(x) {
factor =,
f = col_factor(),
double =,
numeric =,
d = col_double(),
integer =,
i = col_integer(),
Expand Down
32 changes: 18 additions & 14 deletions man/cols.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a08db02

Please sign in to comment.