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 <- read_csv(readr_example("mtcars.csv"))
#> Parsed with column specification: #> cols( #> mpg = col_double(), #> cyl = col_integer(), #> disp = col_double(), #> hp = col_integer(), #> drat = col_double(), #> wt = col_double(), #> qsec = col_double(), #> vs = col_integer(), #> am = col_integer(), #> gear = col_integer(), #> carb = col_integer() #> )
s <- spec(df) s
#> cols( #> mpg = col_double(), #> cyl = col_integer(), #> disp = col_double(), #> hp = col_integer(), #> drat = col_double(), #> wt = col_double(), #> qsec = col_double(), #> vs = col_integer(), #> am = col_integer(), #> gear = col_integer(), #> carb = col_integer() #> )
cols_condense(s)
#> cols( #> .default = col_integer(), #> mpg = col_double(), #> disp = col_double(), #> drat = col_double(), #> wt = col_double(), #> qsec = col_double() #> )