df_schema: Describe the schema of a data frame, suitable for sending to...

View source: R/schema.R

df_schemaR Documentation

Describe the schema of a data frame, suitable for sending to an LLM

Description

df_schema() gives a column-by-column description of a data frame. For each column, it gives the name, type, label (if present), and number of missing values. For numeric and date/time columns, it also gives the range. For character and factor columns, it also gives the number of unique values, and if there's only a few (<= 10), their values.

The goal is to give the LLM a sense of the structure of the data, so that it can generate useful code, and the output attempts to balance between conciseness and accuracy.

Usage

df_schema(df, max_cols = 50)

Arguments

df

A data frame to describe.

max_cols

Maximum number of columns to includes. Defaults to 50 to avoid accidentally generating very large prompts.

Examples

df_schema(mtcars)
df_schema(iris)

ellmer documentation built on July 14, 2026, 1:07 a.m.