col_rep() allows for a simple specification of column types for use in read functions. Enter in a letter followed by a number to repeat that type that number of times.

Supports output for use in readr and readxl, and other functions that take column type specifications in the same format.

col_rep(str, spec_type = "readr")

Arguments

str

String specifying the expansion.

spec_type

String. Either "readr" for short letter notation (e.g., ccnnndcc) or "readxl" for long vector notation (e.g., c("text", "text", "numeric"))

Value

An expanded string or a vector of column type specifications.

Examples

col_rep("c3n2dl3-2c")
#> [1] "cccnndlll--c"

col_rep("c3n2dl3-2c", "readxl")
#>  [1] "text"    "text"    "text"    "numeric" "numeric" "numeric" "logical"
#>  [8] "logical" "logical" "skip"    "skip"    "text"