cols_condense() takes a spec object and condenses its definition by setting the default column type to the most frequent type and only listing columns with a different type.

spec() extracts the full column specification from a tibble created by readr.

cols_condense(x)

spec(x)

Arguments

x

The data frame object to extract from

Value

A col_spec object.

Examples

df <- vroom(vroom_example("mtcars.csv"))
#> Observations: 32 #> Variables: 12 #> chr [ 1]: model #> dbl [11]: mpg, cyl, disp, hp, drat, wt, qsec, vs, am, gear, carb #> #> Call `spec()` for a copy-pastable column specification #> Specify the column types with `col_types` to quiet this message
s <- spec(df) s
#> cols( #> model = col_character(), #> mpg = col_double(), #> cyl = col_double(), #> disp = col_double(), #> hp = col_double(), #> drat = col_double(), #> wt = col_double(), #> qsec = col_double(), #> vs = col_double(), #> am = col_double(), #> gear = col_double(), #> carb = col_double() #> )
cols_condense(s)
#> cols( #> .default = col_double(), #> model = col_character() #> )