A function to create a data dictionary for a data frame, a tibble, or a data library. The function will generate a tibble of information about the data. The tibble will contain the following columns:

  • Name: The name of the data object.

  • Column: The name of the column.

  • Class: The class of the column.

  • Label: The value of the label attribute.

  • Description: A description applied to this column.

  • Format: The value of the format attribute.

  • Width: The max character width of the data in this column.

  • Justify: The justification or alignment attribute value.

  • Rows: The number of data rows.

  • NAs: The number of NA values in this column.

dictionary(x)

Arguments

x

The input library, data frame, or tibble.

See also

libname to create a data library. Also see the dsattr function to set attributes for your dataset from within a datastep. To render attributes, see the fmtr package.

Examples

# Create temp directory
tmp <- tempdir()

# Create library
libname(dat, tmp)

# Add data to the library
lib_add(dat, beaver1)
lib_add(dat, iris)

# Examine the dictionary for the library
dictionary(dat)
# A tibble: 9 x 10
#   Name    Column       Class   Label Description Format Width Justify  Rows   NAs
#   <chr>   <chr>        <chr>   <lgl> <lgl>       <lgl>  <lgl> <lgl>   <int> <int>
# 1 beaver1 day          numeric NA    NA          NA     NA    NA        114     0
# 2 beaver1 time         numeric NA    NA          NA     NA    NA        114     0
# 3 beaver1 temp         numeric NA    NA          NA     NA    NA        114     0
# 4 beaver1 activ        numeric NA    NA          NA     NA    NA        114     0
# 5 iris    Sepal.Length numeric NA    NA          NA     NA    NA        150     0
# 6 iris    Sepal.Width  numeric NA    NA          NA     NA    NA        150     0
# 7 iris    Petal.Length numeric NA    NA          NA     NA    NA        150     0
# 8 iris    Petal.Width  numeric NA    NA          NA     NA    NA        150     0
# 9 iris    Species      factor  NA    NA          NA     NA    NA        150     0

# Clean up
lib_delete(dat)