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 value of the width attribute if any have been assigned.

  • Justify: The justification or alignment attribute value.

  • Rows: The number of data rows.

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

  • MaxChar: The maximum character length of the values in this column with no padding.

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 MaxChar
#   <chr>   <chr>        <chr>   <lgl> <lgl>       <lgl>  <lgl> <lgl>   <int> <int>   <int>
# 1 beaver1 day          numeric NA    NA          NA     NA    NA        114     0       3
# 2 beaver1 time         numeric NA    NA          NA     NA    NA        114     0       4
# 3 beaver1 temp         numeric NA    NA          NA     NA    NA        114     0       5
# 4 beaver1 activ        numeric NA    NA          NA     NA    NA        114     0       1
# 5 iris    Sepal.Length numeric NA    NA          NA     NA    NA        150     0       3
# 6 iris    Sepal.Width  numeric NA    NA          NA     NA    NA        150     0       3
# 7 iris    Petal.Length numeric NA    NA          NA     NA    NA        150     0       3
# 8 iris    Petal.Width  numeric NA    NA          NA     NA    NA        150     0       3
# 9 iris    Species      factor  NA    NA          NA     NA    NA        150     0      10

# Clean up
lib_delete(dat)