Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

descriptions

Get or set descriptions for data frame columns


Description

The descriptions function extracts all assigned description attributes from a data frame, and returns them in a named list. The function also assigns description attributes from a named list.

Usage

descriptions(x)

descriptions(x) <- value

Arguments

x

A data frame or tibble

value

A named list of description values.

Details

If descriptions are assigned to the "description" attributes of the data frame columns, the descriptions function will extract those values. The function will return the description values in a named list, where the names correspond to the name of the column that the description was assigned to. If a column does not have a description attribute assigned, that column will not be included in the list.

When used on the receiving side of an assignment, the function will assign descriptions to a data frame. The description values should be in a named list, where each name corresponds to the name of the data frame column to assign values to.

Value

A named list of description values.

See Also

fdata to display formatted data, value to create user-defined formats, and fapply to apply formatting to a vector.

Examples

# Take subset of data
df1 <- mtcars[1:10, c("mpg", "cyl") ]

# Print current state
print(df1)

# Assign descriptions
descriptions(df1) <- list(mpg = "Miles per Gallon", cyl = "Cylinders")

# Display descriptions
descriptions(df1)

fmtr

Easily Apply Formats to Data

v1.5.0
CC0
Authors
David Bosak
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.